- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最近我们更改了多个依赖项 - 并清理了旧代码我们的 springSecurityFilterChain 代码被破坏了我在网上搜索了多个链接所有这些都没有帮助。
只是为了澄清 - 应用程序上下文启动 - 只有在向我的应用程序发出 http 请求时才会发生错误
https://www.baeldung.com/no-bean-named-springsecurityfilterchain-is-defined
getting exception: No bean named 'springSecurityFilterChain' is defined
No bean named 'springSecurityFilterChain' is defined - Spring 4 Java configuration
Spring Security: No bean named 'springSecurityFilterChain' is defined
以上所有与我的情况无关的类似错误
我的 web.xml
<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_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>com.company.core.servlet.CompanyDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:webApplicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/v1/*</url-pattern>
<url-pattern>/v2/*</url-pattern>
<url-pattern>/services/*</url-pattern>
<url-pattern>/api/*</url-pattern>
</filter-mapping>
我的 webApplicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd"
>
我的错误堆栈跟踪:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:785) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1227) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:295) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1112) ~[spring-context-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:338) ~[spring-web-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:264) ~[spring-web-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at com.samaxes.filter.NoCacheFilter.doFilter(NoCacheFilter.java:65) ~[cachefilter-2.0.jar:2.0]
at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602) ~[jetty-security-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ContextHandler.__doHandle(ContextHandler.java:1435) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:42020) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) ~[jetty-servlet-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633) ~[jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380) [jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273) [jetty-server-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:540) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:395) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:161) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [jetty-io-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905) [jetty-util-9.4.35.v20201120.jar:9.4.35.v20201120]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
最佳答案
如果您的资源导入正确,则声明一个简单的 <http>
你的 webApplicationContext.xml
中的元素文件将确保过滤器 bean 被创建并且一切都正确启动:
<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
</http>
关于java - 如何解决 No bean named 'springSecurityFilterChain' available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72330286/
在使用Spring Boot 3.0.7并试图保持更新时,我遇到了这个错误,不知道它是什么意思。。加载的依赖项是Spring Security 6.0.9,问题存在于使用Java 17或19的情况下(
我正在使用 Spring Boot 1.4.0.M2 并且我编写了以下测试用例以确保具有 spring 安全性的 Controller 正常运行。 @RunWith(SpringRunner.clas
我是 Spring Security 的新手。通过遵循一些文章,我创建了一个启用安全性的 Spring 应用程序。但问题是,每当我运行该项目时,它都会遇到异常。但是,当我从 web.xml 中注释 D
当我尝试运行项目时,Tomcat 返回异常。 有人可以帮助解决这个问题吗? 配置类:https://github.com/intrade/inventory/blob/master/src/main/
所以我环顾四周,到处都说我需要检查我的配置,但对我来说没有意义的是我的应用程序将在另一台计算机上运行,而不是我用于开发的计算机。只是为了提供一些上下文,这个应用程序纯粹是通过 token 身份验证
当我将spring-boot-starter-actuator依赖项添加到我的pom.xml时,我收到一个异常“创建名称为'springSecurityFilterChain'的bean时出错”没有它
我正在尝试构建使用 Spring 安全性的应用程序,但出现异常: Exception in thread "main" org.springframework.beans.factory.BeanCr
我在 Spring Boot 中使用 oauth2,我有一个登录并且工作正常,但是当我实现资源服务器时,它不起作用并且我收到一些错误,我的代码: 类配置 @Configuration @EnableA
尝试在 Spring 测试我的 WebSecurityAdapterConfig.class...编译器请求注入(inject) filterChainproxy 但在为 springSecurity
当我将 springSecurityFilterChain 的 bean 定义放在 web.xml 中时,我得到一个错误,指出 Tomcat 7 将不会启动,因为有一个 duplicate bean
我需要将 spring security 与使用 spring 3.1.1 构建的小型应用程序集成,如下 this教程在 3.2.1 点,得到了这个错误跟踪: gen 31, 2014 3:08:41
我收到错误 No bean named 'springSecurityFilterChain' available 当我不包含 spring 安全配置时,我的代码工作正常。该项目是使用基于 sprin
我正在使用 spring、hibernate 和 primefaces 开发一个 Web 应用程序。 在此应用程序中,我从数据库获取数据并使用它来显示图表。 当我运行我的应用程序时,出现此错误: or
我在设置 Spring Security 时遇到一些问题似乎找不到 springSecurityFilterChain bean我的 Spring 安全配置:
最近我们更改了多个依赖项 - 并清理了旧代码我们的 springSecurityFilterChain 代码被破坏了我在网上搜索了多个链接所有这些都没有帮助。 只是为了澄清 - 应用程序上下文启动 -
当我运行我的项目时,我得到一个 nullpointerexception。 我几乎查看了所有与这种由“springSecurityFilterChain”引起的空指针异常相关的 stackoverfl
我正在使用 Spring Security(spring-boot-starter-web 和 spring-boot-starter-security)构建 Spring Boot 应用程序。我的应
我一直在关注Spring Security Reference我只添加了这个类: @Configuration @EnableWebMvcSecurity public class WebSecuri
我正在尝试使用 Spring 3.1.2-Release 编写应用程序。应用服务器是 Tomcat 7。当我启动服务器时,出现此错误: SEVERE: Exception starting filte
我正在从引用资料中学习 Spring 安全性。发布 3.1.2.RELEASE。如前所述,我已经像这样配置了 security:http 标记 security-context.xml
我是一名优秀的程序员,十分优秀!