java - 创建名为“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 文件。
解决方案
我通过使用找到了解决方法
-DskipTests
但我认为应该有更好的解决方案来摆脱这个奇怪的错误。
推荐阅读
- razor - Insight into inheriting from a base controller class
- html - 遇到麻烦
在 CSS 中 - javascript - URL 编码正在破坏 ExtJS 中的路由
- mysql - 在 mysql 中更新表后触发错误 1054
- performance - clflush 是否也会删除 TLB 条目?
- github - 无法使用 Script Lab 共享脚本
- jquery - 具有自定义分页和动态列的 Kendo Grid(JQuery)
- java - 在json序列化中将具有String成员变量的对象转换为单个String的简单方法(Jackson)
- ajax - 饼干在哪里吃?
- python - 无法覆盖关联对象中的对象属性