2dor
2dor

Reputation: 1001

Actuator endpoints not available in multi-module SpringBoot application

I have a multi module SpringBoot application that has the following modules:

In "api" layer I maintain all controllers and dtos and in application I add the dependencies to the modules and I build my SpringBoot (version 2.6.6) application. I am trying to add now Spring Boot Actuator with a custom info endpoint that also displays the app version and to see all endpoints in OpenAPI dashboard. For some reason, I can't get this to work, I just get 403 for everything actuator related and I don't see endpoints in OpenAPI (V3).

What I have is the following:

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

application.properties:

management.security.enabled = false
springdoc.show-actuator=true

I have also added these lines in my security config (maybe api prefix intervenes somehow)

.antMatchers(apiPrefix + "/actuator/**").permitAll() //I have a API prefix for all backend calls
.antMatchers("/actuator/**").permitAll()

In "application" as well I have defined the spring-boot-maven-plugin:

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

How do I fix my code?

Upvotes: 2

Views: 878

Answers (1)

Attila T
Attila T

Reputation: 597

It's unclear what version of Spring Boot you're using. Starting from 2.0 you have to enable and expose actuator related end-points of your choice.

The following should tell you what are currently available for your application:

GET http://<host>:<port>/actuator

For example, the snippet from application.yaml below should enable and expose only the info and health end-points:

management:
  endpoints:
    enabled-by-default: false
    web:
      exposure:
        include:
          - info
          - health
  endpoint:
    health:
      enabled: true
    info:
      enabled: true

The Spring Reference Documentation should give you more details.

Upvotes: -1

Related Questions