Context
I am working on a Spring Boot application (Spring Boot 3.3, Java 17) and want to add monitoring capabilities.
Task:
Configure the project to use Spring Boot Actuator and expose basic endpoints.
Constraints:
-
Use Maven or Gradle for dependency management.
-
The
healthandinfoendpoints must be exposed over the web. -
The
metricsendpoint should NOT be exposed over the web. -
All actuator endpoints should be available under the path
/managementinstead of the default/actuator.
Steps:
-
Add the
spring-boot-starter-actuatordependency to the build file. -
Modify the
application.propertiesorapplication.ymlfile to:a. Change the base path for management endpoints to
/management.b. Explicitly expose only the
healthandinfoendpoints. -
Provide the
curlcommands to verify the endpoints after running the application.
Deliverables:
-
The Maven/Gradle dependency XML/Groovy snippet.
-
The required lines for
application.properties. -
curlcommands to testhttp://localhost:8080/management/healthandhttp://localhost:8080/management/info. -
curlcommand to verify thathttp://localhost:8080/management/metricsreturns a 404 Not Found.
Acceptance Criteria for your AI-generated code:
• The application compiles and runs with the new dependency.
• Accessing /management/health returns a JSON response with "status": "UP".
• Accessing /management/info returns an empty JSON object {}.
• Accessing /management/metrics returns a 404 HTTP status.