Problems with Eureka Health Checks in Spring Application
Asked Answered
A

3

5

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!

Acquainted answered 5/12, 2017 at 8:14 Comment(0)
Y
3

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

Yellowgreen answered 22/1, 2019 at 6:29 Comment(0)
B
0

Yes. In order to use production ready features like Auditing, Health check, Metric gethering, etc., you need to provide the spring-boot-starter-actuator starter dependency as mention in Spring Doc itself. You can refer this site for a quick introduction.

Bramlett answered 5/4, 2019 at 12:17 Comment(0)
E
0

The spring-boot version is not compatible with spring-cloud-starter-netflix-eureka-client. Match them by the release date.

Eclair answered 21/4, 2020 at 2:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.