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的版本号与父工程保持一致。(非最优)