如何解决 Spring Boot 3.2.0 和 java 17 中的 netflix eureka 客户端错误

Bad*_*ker 1 java spring-boot netflix-eureka

我正在尝试使用 java 17 在新的 spring boot 3.2.0 应用程序中配置 eureka 客户端,并在运行时出现以下错误。

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaClient' parameter 3: No qualifying bean of type 'com.netflix.discovery.shared.transport.jersey.TransportClientFactories<?>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我正在使用下面的 Maven 依赖项,没有其他配置。

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
   <version>4.1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

请注意,如果我删除此依赖项,我不会看到任何错误。\

主班

@SpringBootApplication
public class SpringBoot3Java17Application {

    public static void main(String[] args) {
        SpringApplication.run(CommissionManagerApplication.class, args);
    }

}
Run Code Online (Sandbox Code Playgroud)

application.properties:(并且还需要应用程序如何跟踪本地运行的尤里卡服务器的帮助)

eureka.client.service-url.defaultZone=http://admin:alined@localhost:8761/eureka/
Run Code Online (Sandbox Code Playgroud)

应用程序已启动但未向 Eureka 注册: 在此输入图像描述

尤里卡服务器: 在此输入图像描述

在使用 spring boot 3.2.0 和 java 17 配置 eureka netflix 客户端时需要帮助

谢谢你!

小智 5

当我升级到 Spring Boot 3.2.1 和 Spring Cloud Dependency 2023.0.0 时,我遇到了同样的问题。
我设法通过添加以下依赖项解决了该问题:

<dependency>
    <groupId>com.netflix.eureka</groupId>
    <artifactId>eureka-client-jersey3</artifactId>
 </dependency>
Run Code Online (Sandbox Code Playgroud)

并创建以下 bean:

import com.netflix.discovery.shared.transport.jersey3.Jersey3TransportClientFactories;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Jersey3TransportClientFactoriesConfig {

    @Bean
    public Jersey3TransportClientFactories jersey3TransportClientFactories() {
        return new Jersey3TransportClientFactories();
    }

}
Run Code Online (Sandbox Code Playgroud)