簡體   English   中英

Netflix eureka客戶端微服務未在eureka服務器上注冊

[英]Netflix eureka client micro-service is not registering with eureka server

我正在嘗試使用eureka服務器注冊我的微服務。 但它顯示瀏覽器中沒有可用的實例。 我在控制台中沒有出現任何錯誤。 請幫我解決這個問題。

我已經通過谷歌搜索嘗試了多個選項。 不過,我無法解決這個問題。

微服務application.properties

  spring.application.name=jecreations-core
  eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
  eureka.client.register-with-eureka=true

客戶主類

 @EnableEurekaClient
 @SpringBootApplication
 @EnableConfigurationProperties(ImageProperties.class)
 public class JecreationsApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
    SpringApplication.run(JecreationsApplication.class, args);
}
 }

Eureka Server application.properties

   eureka.client.register-with-eureka=false
   eureka.client.fetch-registry=false
   server.port=8761
   spring.application.name=DiscoveryServer

尤里卡服務器主類。

 @SpringBootApplication
 @EnableEurekaServer
 public class JeeurekaApplication extends SpringBootServletInitializer{

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

}

您需要使用標注eureka服務器主類

@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient

public class EurekaServerApplication {

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

此外,您需要使用以下內容注釋客戶端的主類:

@SpringBootApplication
@EnableDiscoveryClient
public class MicroApplication {

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

您需要在eureka客戶端的application.yml中進行以下配置:

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

在Eureka Server application.yml文件中,我有以下配置:

info:
  component: Eureka Server

server: 
  port: 8761


eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    enable-self-preservation: false
    waitTimeInMsWhenSyncEmpty: 0
  instance:
    hostname: localhost
    lease-expiration-duration-in-seconds: 15
    lease-renewal-interval-in-seconds: 5

試試這樣吧

eureka服務器配置

eureka.client.registerWithEureka= false
eureka.client.serviceUrl.defaultZone= ${EUREKA_URI:http://localhost:8761/eureka}

eureka客戶端配置

eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka
eureka.instance.preferIpAddress= true

仍然面臨問題請關注我的回復https://github.com/vimaleshJeyavelmani/spring-boot-micros

謝謝,
Vimalesh

問題在於尤里卡客戶的依賴性。 我已經給了這種依賴

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

代替

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

謝謝你的回復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM