Alex Mi
Alex Mi

Reputation: 1459

spring boot actuator does not work as expected

I am starting to learn spring boot and I have just imported my spring-actuator in my pom.xml. Now, the endpoint

http://localhost:8080/actuator/health

works correctly, and the endpoint below

http://localhost:8080/actuator/

shows me the following information:

{"_links":{"self":{"href":"http://localhost:8080/actuator","templated":false},"health":{"href":"http://localhost:8080/actuator/health","templated":false},"health-path":{"href":"http://localhost:8080/actuator/health/{*path}","templated":true}}}

However, in the folder

src/main/resources

I added the file

application.properties

which contains the following properties:

info.app.name=My Super Cool App
info.app.description=A crazy and fun app, yahoo!
info.app.version=1.0.0

I expect that the above mentioned properties are shown under the endpoint

http://localhost:8080/actuator/info

however, the endpoint above gives me the following error message:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Sep 18 13:03:31 CEST 2021
There was an unexpected error (type=Not Found, status=404).
No message available

Where is my error?

Below, you can find an excerpt from my pom.xml:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.4</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.luv2code.springboot.demo</groupId>
    <artifactId>mycoolap</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>mycoolap</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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

Thank you very much!

Upvotes: 0

Views: 1031

Answers (1)

Alex Mi
Alex Mi

Reputation: 1459

It seems that in the version of Spring Boot I am using, the endpoint /acturator/info is not exposed by default, as it is in earlier versions of spring-boot.

To expose it, I added the entry

management.endpoints.web.exposure.include=*

in my

application.properties

file and it worked.

Kind regards, Alex

Upvotes: 3

Related Questions