spring-boot-actuator - SpringBoot2中的自定义导航执行器端点
问题描述
我编写了 Spring-Boot 版本 2,自定义端点执行器代码,并尝试使用 @Selector 选项使其可导航,
1) 当我在浏览器中输入 URL http://localhost/actuator/notes/1.0时,它给了我 400 作为错误代码,预期的输出应该是 ** Version 1.0 **
2) 当我在浏览器中输入 URL http://localhost/actuator/notes时,它给了我预期的输出,即 ** 1.1 版 ** ** 1.0 版 **
@Component
@Endpoint(id="notes")
public class NotesEndPoint {
String notesOne=" ** Version 1.0 ** ";
String notesTwo = "** Version 1.1 **";
@ReadOperation
public String selectNotes(@Selector String selector ) {
if("1.0".equals(selector)) return notesOne ;
else if("1.1".equals(selector)) return notesTwo ;
else return getNotesVersion();
}
@ReadOperation
public String getNotesVersion(){
return notesTwo + notesOne;
}
}
解决方案
推荐阅读
- c# - 有没有办法删除被算作一个字符的空格?
- css - 如何在背景顶部创建曲线?
- javascript - TypeError:无法读取未定义的属性“评级”
- javascript - 如何获取
- reactjs - Browserslist:caniuse-lite 已过时。请运行下一个命令`yarn upgrade`
- reverse-engineering - Windows 10 1909 在 Bochs 中运行非常缓慢
- asp.net - asp .net core 日期时间显示格式
- javascript - 如何在滚动时突出显示/更改颜色为 div
- c++ - (如何)对于初始化指针的数组上的后递增索引,我能否摆脱 C6386 警告?
- google-cloud-storage - 将大文件从 Google Cloud Storage 读取到 Rstudio