创建名为“compositeCompatibilityVerifier”的 bean 时出错

ppb*_*ppb 6 spring-boot

我正在使用Spring Boot 2.5.5with Spring Cloud Version 2020.0.4,但是当我尝试运行该应用程序时,我遇到了异常 -

Exception encountered during context initialization - cancelling refresh attempt:     
org.springframework.beans.factory.BeanCreationException: Error creating bean with name  
'compositeCompatibilityVerifier' defined in class path resource [org/springframework 
/cloud/configuration/CompatibilityVerifierAutoConfiguration.class]: Bean instantiation  
via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.cloud.configuration.CompositeCompatibilityVerifier]: Factory 
 method 'compositeCompatibilityVerifier' threw exception; nested exception is 
 org.springframework.cloud.configuration.CompatibilityNotMetException
Run Code Online (Sandbox Code Playgroud)

pom.xml

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

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>2020.0.4</spring-cloud.version>
</properties>

<dependencies>
    <!-- Below jar file also has same Spring Boot Version -->
    <dependency>
        <groupId>com.another.project</groupId>
        <artifactId>commons</artifactId>
        <version>1</version>
        <scope>compile</scope>
    </dependency>

    <!-- other spring boot dependency -->
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

我有另一个项目jar,其中pom也有相同的项目Spring Boot Version,我怀疑会导致问题,但不确定如何?

Aug*_*tto 2

pom看起来不错。我唯一建议的是检查弹簧组件的兼容性。spring.io页面有一个兼容性矩阵,您应该仔细检查您尝试使用的版本是否与 Spring Boot 兼容

您可以尝试的第二件事是根本没有父 POM,而是从其 pom-s 导入 spring boot 和 spring cloud 依赖项。

您添加了 Spring Cloud,对于 Spring Boot 执行以下操作:

<dependencyManagement>
     <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)