首页 > 解决方案 > 创建名为“configDataContextRefresher”的 bean 时出错 [SpringBoot]

问题描述

我正在做一个Spring Boot项目。执行命令时出现奇怪的错误mvn clean install
以下是错误:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configDataContextRefresher' defined in class path resource [org/springframework/cloud/autoconfigure/RefreshAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.refresh.ConfigDataContextRefresher]: Factory method 'configDataContextRefresher' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/ConfigurableBootstrapContext
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.refresh.ConfigDataContextRefresher]: Factory method 'configDataContextRefresher' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/ConfigurableBootstrapContext
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/ConfigurableBootstrapContext
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.ConfigurableBootstrapContext

我真的不明白是什么"configDataContextRefresher"。我确认我的代码中没有使用任何 configDataContextRefresher。此外,来自 的整个错误并没有告诉我代码中发生错误的任何位置。

我一直在尝试解决它 2-3 个小时,也没有在互联网上找到任何东西。

请帮忙。非常感谢 !

---编辑---更多线索,我可以做一个mvn spring-boot:run来运行服务。但我无法构建 jar 文件。

标签: javaspringspring-boot

解决方案


我通过使用找到了解决方法

-DskipTests

但我认为应该有更好的解决方案来摆脱这个奇怪的错误。


推荐阅读