Spring Boot 2.6.6 - Actuator API Reference
I checked the above link and unable to find the /actuator/pause
endpoint. I was not sure if it was my app that was causing the issue, so I created a new MVP from spring initializer and even then pause endpoint is not there.
I remember that there used to be a POST endpoint /actuator/pause
, but how do I enable this on newer versions of Spring Boot(2.6.6 above)?
The below is my MVP's code.
build.gradle
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
application.yml
management:
endpoints.web.exposure.include: '*'
endpoint:
pause.enabled: true
restart.enabled: true
resume.enabled: true
shutdown.enabled: true
And once I start the app and hit
curl --location --request POST 'localhost:8080/actuator/pause'
, its sending 404.
CodePudding user response:
You'll need to make sure that Spring Cloud Commons is included in your project dependencies, since it looks like that's the library that supplies the actuator/pause
endpoint (https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#endpoints).
As the documentation additionally notes:
If you disable the /actuator/restart endpoint then the /actuator/pause and /actuator/resume endpoints will also be disabled since they are just a special case of /actuator/restart.
CodePudding user response:
It looks like you should add the following dependency to your build.gradle
file
implementation 'org.springframework.cloud:spring-cloud-starter:3.1.1
You can see that RestartEndpoint
and
RestartEndpoint.PauseEndpoint
classes actually are defined in this package.
Obviously you should change the application.yml
like this:
management:
endpoints.web.exposure.include: '*'
endpoint:
pause:
enabled: true
restart:
enabled: true