我正在开发 Spring Boot JWT 示例,在此示例中为
https://github.com/nydiarra/springboot-jwt
我只是简单地更新了 maven 依赖关系:
<version>1.5.3.RELEASE</version>
至<version>1.5.13.RELEASE</version>
。
我们如何解决以下错误?
org.springframework.beans.factory.BeanCreationException:使用名称&#39; springSecurityFilterChain&#39;创建bean时出错。在类路径资源中定义[org / springframework / security / config / annotation / web / configuration / WebSecurityConfiguration.class]:通过工厂方法的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[javax.servlet.Filter]:工厂方法&#39; springSecurityFilterChain&#39;抛出异常;嵌套异常是org.springframework.beans.factory.BeanNotOfRequiredTypeException:Bean命名为&#39; corsFilter&#39;预计属于&#39; org.springframework.web.filter.CorsFilter&#39;但实际上是&#39; org.springframework.boot.web.servlet.FilterRegistrationBean&#39; 在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1181)~ [spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1075)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:312)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)〜[spring-context-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)〜[spring-context-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)~ [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:303)[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE] 在com.nouhoun.springboot.jwt.integration.SpringbootJwtApplication.main(SpringbootJwtApplication.java:10)[classes /:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)〜[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)〜[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)〜[na:1.8.0_161] at java.lang.reflect.Method.invoke(Unknown Source)〜[na:1.8.0_161] 在org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)[spring-boot-devtools-1.5.13.RELEASE.jar:1.5.13.RELEASE] 引起:org.springframework.beans.BeanInstantiationException:无法实例化[javax.servlet.Filter]:工厂方法&#39; springSecurityFilterChain&#39;抛出异常;嵌套异常是org.springframework.beans.factory.BeanNotOfRequiredTypeException:Bean命名为&#39; corsFilter&#39;预计属于&#39; org.springframework.web.filter.CorsFilter&#39;但实际上是&#39; org.springframework.boot.web.servlet.FilterRegistrationBean&#39; 在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] 在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)〜[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] ...省略了25个常见帧