Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netflix eureka client micro-service is not registering with eureka server

I am trying to register my microservice with the eureka server. But it shows no instances available in the browser. I do not get any error in the console. Please help me in resolving this.

I already tried multiple options by searching on google. Still, I am unable to resolve the issue.

Microservice application.properties

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

client main class

 @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

Eureka server main class.

 @SpringBootApplication
 @EnableEurekaServer
 public class JeeurekaApplication extends SpringBootServletInitializer{

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

}
like image 695
Mohan Gummadi Avatar asked Nov 22 '25 10:11

Mohan Gummadi


2 Answers

The problem is with dependency of eureka client. I have given this dependency

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

instead of

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

Thanks for the responses.

like image 136
Mohan Gummadi Avatar answered Nov 23 '25 23:11

Mohan Gummadi


You need to annotate the eureka server main class with

@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient

public class EurekaServerApplication {

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

Additionally you need annotate you client's main class with:

@SpringBootApplication
@EnableDiscoveryClient
public class MicroApplication {

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

You need the below configuration in application.yml of the eureka client:

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

In the Eureka Server application.yml file I have this configurations:

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
like image 34
Bilal Demir Avatar answered Nov 24 '25 01:11

Bilal Demir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!