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;
}
}
只需要三个注解@endpoint、@ReadOperation、@Selector
启动springboot项目
看到红色mapped就说明可以成功了
访问http://127.0.0.1:8080/actuator/customPoint/156
结果