Spring Boot 的 Endpoints 帶着強烈的 DevOps 色彩, “you build it, you run it” ,開發不僅要關心如何實現功能,還需要關心服務在線上運行的狀態,如果缺乏實時監控,維護線上服務必然是一場噩夢。
/** * An endpoint that can be used to expose useful information to operations. Usually * exposed via Spring MVC but could also be exposed using some other technique. Consider * extending {@link AbstractEndpoint} if you are developing your own endpoint. * * @param <T> the endpoint data type * @author Phillip Webb * @author Dave Syer * @author Christian Dupuis * @see AbstractEndpoint */ public interface Endpoint<T> { /** * The logical ID of the endpoint. Must only contain simple letters, numbers and '_' * characters (i.e. a {@literal "\w"} regex). * @return the endpoint ID */ String getId(); /** * Return if the endpoint is enabled. * @return if the endpoint is enabled */ boolean isEnabled(); /** * Return if the endpoint is sensitive, i.e. may return data that the average user * should not see. Mappings can use this as a security hint. * @return if the endpoint is sensitive */ boolean isSensitive(); /** * Called to invoke the endpoint. * @return the results of the invocation */ T invoke(); }
demo
https://412887952-qq-com.iteye.com/blog/2380027
Springboot admin
ref
https://docs.spring.io/spring-boot/docs/1.1.x/reference/htmlsingle/#production-ready-endpoints
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html