Springcloud中服务启动失败报错:org.springframework.beans.factory.BeanDefinitionStoreException

首先,需要知道的是一般报BeanDefinitionStoreException的错,原因在于pom文件的依赖配置问题。然后需要通过详细报错信息(caused by:)去找到错误原因。

关键报错信息:

Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration due to org/springframework/core/annotation/MergedAnnotations$SearchStrategy not found. Make sure your own configuration does not rely on that class. 

报错信息首先看第一个Caused by,可以发先org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration这个包无法被载入,故找到pom文件中的关于actuator的依赖:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>2.2.7.RELEASE</version>
        </dependency>

然后更改版本(版本都可以试一下)

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>2.1.12.RELEASE</version>
        </dependency>

报错详细信息:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.panc.productservice.MProductApplication]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration due to org/springframework/core/annotation/MergedAnnotations$SearchStrategy not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:108) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:808) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_231]
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:804) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:774) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at com.septemberhx.productservice.MProductApplication.main(MProductApplication.java:16) [classes/:?]
Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration due to org/springframework/core/annotation/MergedAnnotations$SearchStrategy not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:53) ~[spring-boot-autoconfigure-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:589) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 19 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEndpointAttributes(AbstractEndpointCondition.java:104) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEndpointAttributes(AbstractEndpointCondition.java:58) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEnablementOutcome(AbstractEndpointCondition.java:64) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnAvailableEndpointCondition.getMatchOutcome(OnAvailableEndpointCondition.java:51) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:46) ~[spring-boot-autoconfigure-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:589) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 19 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.annotation.MergedAnnotations$SearchStrategy
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_231]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_231]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[?:1.8.0_231]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_231]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEndpointAttributes(AbstractEndpointCondition.java:104) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEndpointAttributes(AbstractEndpointCondition.java:58) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.AbstractEndpointCondition.getEnablementOutcome(AbstractEndpointCondition.java:64) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnAvailableEndpointCondition.getMatchOutcome(OnAvailableEndpointCondition.java:51) ~[spring-boot-actuator-autoconfigure-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:46) ~[spring-boot-autoconfigure-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:589) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 19 more


版权声明:本文为baidu_38769016原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。