1. 程式人生 > >spring cloud eureka 遇到的坑

spring cloud eureka 遇到的坑

1.eureka.client.serviceUrl.defaultZone 中defaultZone不等於default-zone

 這樣eureka客戶端會識別不了,會向localhost:8761註冊,造成服務發現混亂。

2. eureka 客戶端 傳遞依賴(間接依賴) javaee-api-8.0 與  eureka傳遞依賴jsr311-api-1.1.1.jar 下javax.ws.rs 相關類衝突

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception;

Caused by: java.lang.RuntimeException: Failed to initialize DiscoveryClient!

Caused by: java.lang.ExceptionInInitializerError: null

Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl

2018-11-28 21:37:36.197 ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.NullPointerException

解決:專案中pom中引入javaee-api “短路優先” 覆蓋傳遞依賴。

3.使用IP進行配置eurake 但是沒有eureka.instance.prefer-ip-address=true時,叢集erueka註冊資訊混亂。