兼容 Spring Eureka 版本

Compatible Spring Eureka Version

我在 pom.xml 上使用下面的内容,但由于错误我无法启动应用程序 我不想降级 spring boot starter parent version.Is 有什么解决办法吗?

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.4</version>
    </parent>


<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>2.2.9.RELEASE</version>
        </dependency>

我遇到了 belwo 错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@659e0bfd]

您应该添加与 Spring Boot 2.5.x 兼容的 Spring Cloud 2020.0.3,方法是在 dependencyManagement 部分包含 BOM:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2020.0.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

您可以在 the Spring Cloud website 上找到 Spring 云 / Spring 启动兼容性的概述(请参阅 table 发布火车 Spring 启动兼容性).

添加后,您无需针对特定版本的 Spring Cloud Eureka。相反,您可以按如下方式包含 Eureka 依赖项:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>