Home > Net >  Spring actuator in 2.7 not available get 404
Spring actuator in 2.7 not available get 404

Time:09-08

i am trying to get actuator refresh to work and i cant seem to get it to work. I keep getting 404. The application is basic hello world, have not added anything other than a controller which responds with "Hello". That all works.. but i cant seem to get access to the health or info endpoints.. i read these should be available

my versions are: Gradle:

    plugins {
    id 'org.springframework.boot' version '2.7.3'
    id 'io.spring.dependency-management' version '1.0.13.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "2021.0.3")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    implementation 'org.projectlombok:lombok:1.18.22'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'org.springframework.boot:spring-boot-starter-actuator:2.7.3'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

tasks.named('test') {
    useJUnitPlatform()
}

Tried:

Application.properties server: port: 9999

server:
  port: 9999

management:
  health:
    refresh:
      enabled: true

This too:

management:
  info:
    env:
      enabled: true

i dont think the last one is even available in 2.7

Im using the latest actuator which is 2.7.3, and the url im trying is

http://localhost:9999/actuator/health

CodePudding user response:

I'm upgrading our application's spring boot version from 2.6 to 2.7. I had a similar problem, the actuator endpoint did not show up when I changed spring-boot-starter-actuator version from 2.6.11 to any 2.7.* version.

But when I added spring-boot-actuator-autoconfigure dependency manually, the actuator started to work as before.

So try to add org.springframework.boot:spring-boot-actuator-autoconfigure to your to dependencies.

I cant figure out why this solves the problem. It should work without adding this dependency manually. Maybe the changes in the spring autoconfiguration somehow affected the actuator auto configuration.

  • Related