package com.yan.otlan.springboot; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.Selector; import org.springframework.stereotype.Component; @Endpoint(id = "customPoint") @Component public class StatusEndPoint { @ReadOperation public String getCustom(@Selector String name) { return "MyName is ." + name; } }
Only requires three annotations @endpoint
, @ReadOperation
, @Selector
Seeing the red mapped indicates success
Visit http://127.0.0.1:8080/actuator/customPoint /156
Result
##SpringBoot-Actuator-Custom endpoint propertiesClose all endpointsmanagement.endpoints.enabled-by-default: false
management.endpoints.web.base-path: /actuator
http://ip:port/actuator
http://ip:port/myActuator
/myActuator
The above is the detailed content of How to customize the endpoint in SpringBoot2. For more information, please follow other related articles on the PHP Chinese website!