项目启动时控制台抛异常说找不到“springSecurityFilterChain”的bean。
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined问题分析:Web组件加载顺序:Listener→Filter→ServletSpring IOC容器:ContextLoaderListen...
·
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
问题分析:
Web组件加载顺序:Listener→Filter→Servlet
Spring IOC容器:ContextLoaderListener创建
SpringMVC IOC容器:DispatcherServlet创建
springSecurityFilterChain:从IOC容器中找到对应的bean
ContextLoaderListener初始化后,springSecurityFilterChain就在ContextLoaderListener创建的IOC容器中查找所需要的bean,但是我们没有在ContextLoaderListener的IOC容器中写SpringSecurity的配置类,所以springSecurityFilterChain对应的bean找不到。
问题解决:
将ContextLoaderListener取消,原本由ContextLoaderListener读取的Spring配置文件交给DispatcherServlet负责读取。
更多推荐
已为社区贡献1条内容
所有评论(0)