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负责读取。

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐