Enabling or disabling endpoints

By default in Spring Boot, all endpoints are enabled except /shutdown, but you can disable some of them. You can also enable the /shutdown endpoint.

In the application.properties file, it would look like this:

endpoints.shutdown.enabled=true 

In the application.yml file, it would look like this:

endpoints:
   shutdown:
         enabled: true 

Similarly, you can also disable any of the other endpoints as follows:

endpoints._endpoint-id.enabled = false

In the application.yml file, it would look like this:

endpoints:
   _endpoint-id:
         enabled: false 

Let's suppose you want to disable the /health endpoint. Then in the application.properties file, you have to set the following property:

endpoints.health.enabled=true 

In application.yml ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.