Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Eureka Health Checks in Spring Application

I'm developing a Spring based application that consists of several microservices. One of my microservices acts as a Eureka server and everything works fine so far.

In all my other microservices (which are annotated with @EnableEurekaClient), I want to enable health checks like this:

application.yml

eureka:
  client:
    healthcheck:
      enabled: true

The first thing I notice, is that my IDE shows me an error:

Cannot resolve configuration property 'eureka.client.healthcheck.enabled'

This happens in both, Intellij Idea and STS, so I assume it's not just an IDE bug!

The start of the application fails with a long UnsatisfiedDependencyException where the root cause is the following:

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.health.OrderedHealthAggregator at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_151] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_151] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_151] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_151] ... 87 common frames omitted

If I add compile('org.springframework.boot:spring-boot-starter-actuator') to my build.gradle file (I assume, this is what the error message wants to tell me), it compiles and starts fine. However, the IDE is still showing me the error above.

My questions are the following:

1. Is it the intended behaviour that actuator needs to be on the classpath if one wants to use Eureka health checks?

2. Why am I getting the error message from my IDE?

Thanks for help!

like image 558
user7346048 Avatar asked Oct 17 '22 02:10

user7346048


1 Answers

I faced exaclty the same issue, however, every thing works find when I added the

compile('org.springframework.boot:spring-boot-starter-actuator')

and the error message disappeared, my recomendation for you is the following:

1- always make sure that all your microservices share the same spring boot version 2- use Spring Initializr https://start.spring.io/ 3- use latest stable version

like image 54
user6880999 Avatar answered Nov 15 '22 07:11

user6880999