SpringBoot2新特性 自定义端点详解

网友投稿 582 2022-12-25

SpringBoot2新特性 自定义端点详解

SpringBoot2新特性 自定义端点详解

SpringBoot2新特性 自定义端点

package com.yan.otlan.springboot;

import org.springframework.boot.actuate.endpoint.annothttp://ation.Endpoint;

import org.springiziFXXxframework.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

结果

SpringBoot-Actuator-自定义端点属性

关闭所有端点

management.endpoints.enabled-by-default: false

修改访问项目路径

默认访问路径为/actuator,可通过修改以下属性进行修改

management.endpoints.web.base-path: /actuator

如默认访问路径为 http://ip:port/actuator

如想将访问路径修改为 http://ip:port/myActuator

可将属性设置为 /myActuator

路径必须以/开始,否则http://无法访问

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring boot actuator端点启用和暴露操作
下一篇:Flutter滚动组件(flutter 滑动控件)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~