- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我将spring-boot-starter-actuator依赖项添加到我的pom.xml时,我收到一个异常“创建名称为'springSecurityFilterChain'的bean时出错” 没有它项目可以正常编译。
15:52:49,448 [ERROR][host-startStop-1][.[Tomcat].[localhost].[/red_tst]] - Exception starting filter springSecurityFilterChain
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1057)
at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326)
at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235)
at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:109)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4583)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 23 more
Caused by: java.lang.NullPointerException
at org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$IgnoredPathsWebSecurityConfigurerAdapter.normalizePath(ManagementWebSecurityAutoConfiguration.java:179)
at org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$IgnoredPathsWebSecurityConfigurerAdapter.init(ManagementWebSecurityAutoConfiguration.java:167)
at org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$IgnoredPathsWebSecurityConfigurerAdapter.init(ManagementWebSecurityAutoConfiguration.java:129)
at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.init(AbstractConfiguredSecurityBuilder.java:370)
at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:324)
at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41)
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:105)
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$afc86f48.CGLIB$springSecurityFilterChain$5(<generated>)
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$afc86f48$$FastClassBySpringCGLIB$$ead45fb9.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318)
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$afc86f48.springSecurityFilterChain(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
我的 Spring Security 配置
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
AuthorizationService authService;
@Autowired
CustomAuthenticationSuccessHandler authSuccessHandler;
@Autowired
MDCFilter instanceMDCFilter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers()
.frameOptions().sameOrigin()
.cacheControl().disable()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
.sessionFixation()
.migrateSession()
.and()
.addFilterAfter(instanceMDCFilter,UsernamePasswordAuthenticationFilter.class)
.authorizeRequests()
.antMatchers("/*").permitAll()
.and()
.formLogin()
.loginPage("/login")
.failureUrl("/login?error")
.successHandler(authSuccessHandler)
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/index")
.and()
.rememberMe()
.tokenValiditySeconds(604800)
.and();
}
@Autowired
Md5PasswordEncoder md5Encoder;
@Bean
public Md5PasswordEncoder md5PasswordEncoder(){
return new Md5PasswordEncoder();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(authService)
.passwordEncoder(md5Encoder);
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<version>0.0.1</version>
<packaging>war</packaging>
<repositories>
<repository>
<id>dependency-storage</id>
<url>http:%url%/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>dependency-storage</id>
<url>http:%url%</url>
</pluginRepository>
</pluginRepositories>
<properties>
<start-class>red.Application</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.0.RELEASE</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter-maven-plugin</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-jdk14</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.github.livesense</groupId>
<artifactId>jodconverter-core</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<finalName>name</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
最佳答案
我通过定义一个实现 ErrorController 的 Controller 并让 getErrorPath() 返回 null 来重现异常:
@Controller
public class MyErrorController implements ErrorController {
@RequestMapping("/whatever")
public String myMethod(HttpServletRequest request, HttpServletResponse response) {
return "hello.html";
}
@Override
public String getErrorPath() {
return null;
}
}
所以也许您还在使用错误的 getErrorPath() 方法来实现 ErrorController。
关于java - SpringSecurityFilterChain 和执行器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35132602/
在使用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
我是一名优秀的程序员,十分优秀!