1
votes

Trying to write Eureka Client With Spring Cloud Netflix v1.2.0.Release but facing the below mentioned issue. PFB code and configurations.

EurekaClient.java

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


    @Configuration
    @EnableAutoConfiguration
    @EnableEurekaClient
    @RestController
    @ComponentScan(basePackages={"com.west.eas.netflix.config"})
    public class EurekaClient {

        @RequestMapping("/")
          public String home() {
            return "Hello World";
          }

          public static void main(String[] args) {
              new SpringApplicationBuilder(EurekaClient.class).run(args);
          }


    }

application.yml

server:  
  port: 9000

spring:  
  application:
    name: eas-eureka-client

eureka:  
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    preferIpAddress: true

bootstrap.yml

spring:
  application:
    name: eu-client
  cloud:
    config:
      uri: http://localhost:8888
encrypt:
  failOnError: false

Client fails to start with following error

" Parameter 0 of method eurekaHealthIndicator in org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration$EurekaHealthIndicatorConfiguration required a bean of type 'com.netflix.discovery.EurekaClient' that could not be found."

the below screenshot will have more details on error stack

enter image description here

I even tried setting healthcheck enable to false in application.yml but it still wont work. Any Help would be appreciated.

Regards

2
What are your dependencies?spencergibb
And why do you have different spring.application.names in application and bootstrap?spencergibb

2 Answers

1
votes

The problem seems to be that you are naming your client EurekaClient, There is already a bean with that name. Rename that class to something else and it should work

0
votes

as @spencergibb mentioned it did go wrong in adding dependencies, I've tried creating a new project via http://start.spring.io/ which resolved my issue.