春天菜鸟:好的。我从 STS Spring Starter Project / Maven / Java 8 / Spring Boot 2.0 开始,然后选择 Web 和 Actuator 依赖项。它构建并运行良好,并响应http://localhost:8080/actuator/health。我在主应用程序类中添加了一个“端点”,使其看起来像这样。
package com.thumbsup;
import org.springframework.boot.SpringApplication;
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.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class YourStash11Application {
public static void main(String[] args) {
SpringApplication.run(YourStash11Application.class, args);
}
@Endpoint(id="mypoint")
public class CustomPoint {
@ReadOperation
public String getHello(){
return "Hello" ;
}
}
}
我尝试启用 application.properties 中的所有内容:
management.endpoints.enabled-by-default=true
management.endpoint.conditions.enabled=true
management.endpoint.mypoint.enabled=true
management.endpoints.web.exposure.include=*
但是当它构建时,没有引用映射/actuator/mypoint,并且
http://localhost:8080/actuator/mypoint和
http://localhost:8080/application/mypoint
都返回404错误。
我错过了什么?谢谢!