I am trying to upgrade a spring boot boilerplate project to Spring boot 2.0.0. I followed the official migration guide(this and this) but it is unable to expose the actuator custom endpoints.
I tested with this dummy endpoint:
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;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@Endpoint(id="testing-user")
public class ActiveUsersEndpoint {
private final Map<String, User> users = new HashMap<>();
ActiveUsersEndpoint() {
this.users.put("A", new User("Abcd"));
this.users.put("E", new User("Fghi"));
this.users.put("J", new User("Klmn"));
}
@ReadOperation
public List getAll() {
return new ArrayList(this.users.values());
}
@ReadOperation
public User getActiveUser(@Selector String user) {
return this.users.get(user);
}
public static class User {
private String name;
User(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
}
The endpoints work well if exposed directly from the child project but doesn't work if the endpoints are exposed from the parent boilerplate project which is being added as a dependency.
In my application.yml, I have added:
management:
endpoints:
web:
base-path: /
exposure:
include: '*'
There aren't many resources available and those which are, aren't helping.