3

I have an Eureka Server where I want to register a very basic SpringBoot service. Unfortunately the service doesnt register although I tried to follow all the articles I could find.

Moreover when I check description of the DiscoveryClient (that gets autowired), I see "Spring Cloud No-op DiscoveryClient" which suggests (as per NoopDiscoveryClient.java source) that Eureka client library isnt found.

In pom I have

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

which if I am right should make sure that proper netflix libraries are in place. @EnableEurekaClient annotation is present. No errors on the console when starting the client, nothing interesting in the Eureka Server console logs.

This is the configuration from the application.yml:

    eureka:
      client:
        serviceUrl:
          defaultZone: ${vcap.services.eureka-service.credentials.uri:http://127.0.0.1:8761}/eureka/

Any suggestions are really welcomed as I am running out of ideas :)

Lech Migdal
  • 3,828
  • 5
  • 36
  • 63

2 Answers2

9

http://start.spring.io is your friend. You need to use the starters.

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

and

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>
spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • Works like a charm. I was missing the spring-cloud-starter-eureka. Thank you! – Lech Migdal Mar 23 '16 at 08:22
  • 1
    Why is `spring-boot-starter-web` needed? I faced an issue of client automatically shutting down after it comes up & adding the web-starter helped it stay up. Similar issue [here](https://stackoverflow.com/a/58521794/2173960). Does the web-starter have an endless thread? If so, source code for that? – Vineet Jan 07 '20 at 10:26
0

Except @spencergibb's answer, in my case it also require <spring-cloud.version> inside the <properties>:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.M3</spring-cloud.version>
    </properties>
shellbye
  • 4,620
  • 4
  • 32
  • 44