/actuator/info Endpoint not working with spring boot 2.5.0

Viewed 13708

I upgraded spring boot version in my app from 2.4.4 to 2.5.0 and it stopped exposing /actuator/info endpoint. Here is the pom.xml and application.yml

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.ms</groupId>
    <artifactId>spring-boot-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-boot-test</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <layers>
                        <enabled>true</enabled>
                    </layers>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

application.yml

management:
  endpoints:
    jmx:
      exposure:
        include: "health,info"

With spring boot parent version 2.4.4, the application is able to expose info endpoint but not with 2.5.0.

5 Answers

The correct property for exposing actuator urls over http is management.endpoints.web.​exposure.exclude (web instead of jmx).

In your case, info was exposed earlier not because you had the property you've provided but because it was exposed by default (along with health). But in 2.5.0 it becomes hidden, so now you need to expose it manually.

Add this to application properties to expose the /info endpoint.

management.info.env.enabled = true

In my case, which was a silly mistake, I had the following dependency:

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

Instead of:

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

So I kept on getting Whitelabel Error Page 404 Not found on all /actuator calls

In application.properties

#Actuator
management.endpoints.jmx.exposure.include=health,info,env,beans
management.endpoints.web.exposure.include=health,info,env,beans

Here is a basic gradle build (kotlin dsl) to have three default available endpoints for actuator:

gradle.build.kts

build.gradle.kts
    //Global variables
    val junitVersion = "5.8.2"
    val springVersion = "2.6.4"
    val springWebVersion = "5.3.16"
    
    plugins {
        java
        id("org.springframework.boot") version "2.6.4"
    
    }
    
    group = "org.example"
    version = "1.0-SNAPSHOT"
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
        testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
    
        //spring boot
        implementation("org.springframework:spring-web:$springWebVersion")
        implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
        implementation("org.springframework.boot:spring-boot-starter-actuator:$springVersion")
        testImplementation("org.springframework.boot:spring-boot-starter-test:$springVersion")
    
    }
    
    tasks.getByName<Test>("test") {
        useJUnitPlatform()
    }

application.yml

#tomcat
server:
  port: 7999

#actuator
management:
  endpoints:
    web:
      exposure:
        include: health,info,env,beans

gradlew bootRun:

enter image description here

Actuator endpoint, e.g.:

http://localhost:7999/actuator/health

You have to enable management.info.env.enabled true and you can add any kind of details that you want inside of the property file. like below. and make sure to enable info for web.exposure. all the configurations are like below.


.properties

#enable /actuator/info
management.info.env.enabled=true
management.endpoints.web.exposure.include=info

#custom properties
info.app.name=order-service
info.app.version=1.0.0
info.app.description=you can insert any kind of data in the property file like this
info.author=mafei

.ymal

#enable /actuator/info
management:
  info:
    env:
      enabled: true
  endpoints:
    web:
      exposure:
        include: info

#custom properties
info:
  app:
    name: order-service
    version: 1.0.0
    description: you can insert any kind of data in the property file like this
  author: mafei

You can see the result here.

enter image description here

Related