[英]Spring Security “No bean named 'filterChainProxy' available” error
I followed several tutorials to use Spring security but I still have the same " No bean named 'filterChainProxy' available " issue. 我遵循了一些使用Spring安全性的教程,但是仍然遇到相同的“ No bean named'filterChainProxy'available ”问题。
org.apache.catalina.core.StandardContext.filterStart Exception starting filter [filterChainProxy]
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'filterChainProxy' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:686)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1210)
I use the follow configuration: 我使用以下配置:
web.xml web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
<filter>
<filter-name>filterChainProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>filterChainProxy</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
applicationContext-security.xml 的applicationContext-security.xml文件
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<http auto-config="true">
<intercept-url pattern="/admin**" access="ROLE_USER" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="blabla" password="123456" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
spring-mvc-servlet.xml 弹簧MVC-servlet.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.medkhelifi.tutorials.spring.springregistration"/>
<context:annotation-config/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
I Don't know what I'm missing. 我不知道我在想什么。 Thank you.
谢谢。 I use: Spring: 5.0.5.RELEASE Spring-Security: 3.2.5
我使用:Spring:5.0.5.RELEASE Spring-Security:3.2.5
Spring Security register a bean named springSecurityFilterChain
as mentioned in the Spring Security Reference Guide . Spring Security注册了一个名为
springSecurityFilterChain
的bean,如《 Spring Security参考指南》中所述 。
The DelegatingFilterProxy
, by default, will try to detect a bean with the same name as the name of the filter. 默认情况下,
DelegatingFilterProxy
将尝试检测与过滤器名称相同的bean。 In your case filterChainProxy
. 在您的情况下
filterChainProxy
。 However this fails because, as stated, there is a bean created named springSecurityFilterChain
. 但是,这失败了,因为
springSecurityFilterChain
创建了一个名为springSecurityFilterChain
的bean。
Now you can do 2 things to fix it 现在您可以做两件事来修复它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.