Spring Boot Actuator not working- Whitelabel Error Page

Viewed 2359

Spring Boot Actuator is not working for rest-full application, getting Whitelabel Error Page on browser and below error in console log.

org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /actuator/health

Added below maven dependency.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

I cross checked, jar file available in class path.enter image description here

Spring boot application version

<version>2.4.1</version>

Added properties in application.properties file

management.endpoints.enabled-by-default=true
management.endpoint.info.enabled=true
management.security.enabled=false
management.endpoints.web.exposure.include=*
spring.mvc.throw-exception-if-no-handler-found=true

Unable to access Actuator with below URL's

http://localhost:8090/actuator/health
http://localhost:8090/actuator/
http://localhost:8090/health/

Logs

WARN IN-WKS-435 [nio-8090-exec-1] o.s.w.s.PageNotFound                     : No mapping for GET /actuator/health
WARN IN-WKS-435 [nio-8090-exec-1] o.s.w.s.PageNotFound                     : No handler found for GET /actuator/health
WARN IN-WKS-435 [nio-8090-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /actuator/health]

Note: Apart from this, whole application is working fine.

Kindly suggest if I need to add any additional configuration in our application.

3 Answers

Spring Boot Actuators endpoints could not be picked-up if running within IDE(IntelliJ or Eclipse).

I tried to run jar using below command(outside of IDE) on cmd and it worked for me.

c:\workspace\demo\target\java -jar demo-spring-boot-project.jar

And I was able to access below URL

http://localhost:8090/actuator/health

Encountered this too while running the app through InteliJ IDEA. It turns out I added the spring-boot-starter-actuator dependency but did not tell Maven to reload the project.

Right clicking on the pom.xml file and selecting Maven->Reload project, solved it.

*In this case I see the jar file exists in your classpath, so your problem is different than mine. Leaving this comment so it might help someone else.

I have encountered the same issue while running the project through IntelliJ IDE. I resolved after doing Invalidate Cache & Restart in IntelliJ IDE.

Go to File -> ``Invalidate Cache`.

The Invalidate cache dialog box appears. One can select accordingly to their project.

Related