写在前面,实践Spring Security遇到的坑:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' available
出现该原因是Spring ContextLoaderListener 上下面加载不到该bean,应当让配置ContextLoaderListener上下文的扫描到该包:
/** * @Date 2019-05-03 * @Author lifei */ @Configuration @ComponentScan(basePackages = {"com.hef.spittr", "config"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {EnableWebMvc.class})}) public class RootConfig { }
详细代码在github上:StompUserSpringSecuritySpittr
一、使用下面 Spring Security最简单的配置,就能无偿地得到一个登陆页面
配置DelegatingFilterProxy: