Error creating bean with name ‘org.springframework.security.oauth2.config.annotation.web.configurati

司徒高丽
2023-12-01

出现以下错误主要原因是加入了资源服务器的配置却没有标识该服务为资源服务器。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Post-processing of merged bean definition failed; nested exception is java.lang.TypeNotPresentException: Type javax.servlet.Filter not present
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:63) ~[spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
	at com.zsh.GatewayApplication.main(GatewayApplication.java:16) [classes/:na]
Caused by: java.lang.TypeNotPresentException: Type javax.servlet.Filter not present
	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:1.8.0_261]
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:1.8.0_261]
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_261]
	at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:1.8.0_261]
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:1.8.0_261]
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_261]
	at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:108) ~[na:1.8.0_261]
	at java.lang.Class.getGenericInterfaces(Class.java:913) ~[na:1.8.0_261]
	at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:502) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.as(ResolvableType.java:450) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.as(ResolvableType.java:451) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.as(ResolvableType.java:456) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.as(ResolvableType.java:456) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1341) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1324) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1291) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1281) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.BridgeMethodResolver.isResolvedTypeMatch(BridgeMethodResolver.java:157) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.BridgeMethodResolver.isBridgeMethodFor(BridgeMethodResolver.java:141) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.BridgeMethodResolver.searchCandidates(BridgeMethodResolver.java:120) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:82) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.lambda$buildResourceMetadata$1(CommonAnnotationBeanPostProcessor.java:390) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:324) ~[spring-core-5.3.5.jar:5.3.5]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:389) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:347) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:295) ~[spring-context-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1098) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[spring-beans-5.3.5.jar:5.3.5]
	... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_261]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_261]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_261]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_261]
	at java.lang.Class.forName0(Native Method) ~[na:1.8.0_261]
	at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_261]
	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:1.8.0_261]
	... 43 common frames omitted

2021-10-31 18:29:13.998  WARN 8204 --- [       Thread-8] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
2021-10-31 18:29:13.998  WARN 8204 --- [       Thread-8] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Destruction of the end

Process finished with exit code 1

出现这个问题主要有两种解决方式

第一种:去掉资源服务器的配置
第二种:在启动类上加上@EnableResourceServer注解

再次启动即可成功!

 类似资料:

相关阅读

相关文章

相关问答