Spring Boot 创建名为“compositeCompatibilityVerifier”的Bean时出错

pgx2nnw8  于 2023-02-12  发布在  Spring
关注(0)|答案(3)|浏览(520)

我将Spring Boot 2.5.5Spring 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

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>

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

lmvvr0a8

lmvvr0a81#

你的pom看起来不错。我唯一的建议是检查Spring组件的兼容性。spring.io页面有一个兼容性矩阵,你应该仔细检查你试图使用的版本是否与 Spring Boot 兼容。
你可以尝试的第二件事,是根本没有父POM,而是从它们的pom-s导入spring Boot 和spring cloud依赖项。
你加了Spring Cloud,为春 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>
2w3rbyxf

2w3rbyxf2#

当我使用spring-cloud时,我遇到了同样的问题。版本:2020.0.3并使用版本解决
<spring-cloud.version>2021.0.3</spring-cloud.version>

jtoj6r0c

jtoj6r0c3#

检查您正在使用的spring-cloud与您的spring-boot版本的兼容性:Spring-Cloud

相关问题