SpringBoot2新特性 自定义端点 - Go语言中文社区

SpringBoot2新特性 自定义端点


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

结果

 

 

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_42214817/article/details/82997504
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-05-17 02:45:32
  • 阅读 ( 656 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢