Spring Boot アプリケーションのカスタム エンドポイントを作成しようとしています。カスタム エンドポイントの実装を以下のように記述しました。コードのサイズを小さくするために、インポートなどの余分なものは含めていません。
@Component
public class TestendPoint implements Endpoint<List<String>>{
public String getId() {
return "test";
}
public List<String> invoke() {
List<String> test= new ArrayList<String>();
test.add("Details 1");
test.add("Details 2");
return serverDetails;
}
public boolean isEnabled() {
return true;
}
public boolean isSensitive() {
return false;
}
}
上記のコードを記述したら、アプリケーションを再起動し、/test からエンドポイントにアクセスしようとしました。ただし、エンドポイントは使用できません。以下は、Spring Boot 起動アプリケーションです。
@Configuration
@EnableAutoConfiguration
public class Application{
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
それとは別に、Spring Boot Actuator を実行するためのすべてが揃っています。/info、/metrics などのデフォルトのエンドポイントにアクセスできました。
ここで何か不足している場合は、知識を共有していただけますか。カスタム エンドポイント クラスは、開発者がそれ以上構成しなくても読み込まれると想定しています。