Spring Noob: OK. I start with a STS Spring Starter Project / Maven / Java 8 / Spring Boot 2.0, and select the Web and Actuator dependencies. It builds and runs fine, and reponds to http://localhost:8080/actuator/health. I add an "Endpoint" to the main application class, so that it looks like this.
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" ;
}
}
}
I try to enable everything in application.properties:
management.endpoints.enabled-by-default=true
management.endpoint.conditions.enabled=true
management.endpoint.mypoint.enabled=true
management.endpoints.web.exposure.include=*
But when it builds, there's no reference to mapping /actuator/mypoint, and
http://localhost:8080/actuator/mypoint and
http://localhost:8080/application/mypoint
both return 404 errors.
What am I missing? Thanks!
OK, solved:
@Endpoint(id="mypoint")
@Component
public class myPointEndPoint {
@ReadOperation
public String mypoint(){
return "Hello" ;
}
}
What was missing was the "@Component" annotation. But, where is this in the docs?