java.lang.NoClassDefFoundError:org/springframework/boot/context/properties/ConfigurationPropertiesBean

springcloud 多模块报错日志:

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'bootstrapImportSelectorConfiguration': 
Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError:
org/springframework/boot/context/properties/ConfigurationPropertiesBean

原因:
父工程的parent:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

子工程有自己独立的parent:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

很明显父子工程本来应该有依赖关系,但这里却没有。
我们可以将子工程的parent 指向 父工程。(最优解)
或者 将子工程的parent标签的 spring-boot-starter-parent的版本号与父工程保持一致。(非最优)

posted @ 2022-07-26 17:26  xudong5273  阅读(651)  评论(0)    收藏  举报