您的位置:首页 >SpringBoot2怎么自定义端点
发布于2023-05-12 阅读(0)
扫一扫,手机访问
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

看到红色mapped就说明可以成功了
访问http://127.0.0.1:8080/actuator/customPoint/156
结果

management.endpoints.enabled-by-default: false
默认访问路径为/actuator,可通过修改以下属性进行修改
management.endpoints.web.base-path: /actuator
如默认访问路径为 http://ip:port/actuator
如想将访问路径修改为 http://ip:port/myActuator
可将属性设置为 /myActuator
路径必须以/开始,否则无法访问
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
9