spring securety 中 @EnableWebSecurity 注解: 如果是在Springboot中不加这个注解也没问题
首先看到网上大部分教程在 WebSecurityConfigurerAdapter 进行配置时都加上了@EnableWebSecurity注解, 但是我发现我并没有加这个注解项目也没出现问题。Spring Security 原理,WebSecurityConfigurerAdapter 介绍,@EnableWebSecurity + FilterChainProxy.
结论:原因就在于我是springboot项目,在非Springboot的Spring Web MVC应用中,该注解@EnableWebSecurity需要开发人员自己引入以启用Web安全。而在基于Springboot的Spring Web MVC应用中,开发人员没有必要再次引用该注解,Springboot的自动配置机制WebSecurityEnablerConfiguration已经引入了该注解。
详见: 注解 EnableWebSecurity 启用Web安全.