Мне хотелось бы иметь индикатор работоспособности в моей конфигурации или весенней загрузке. Но мне это не удалось.
У меня есть следующий класс с @comComponent, но когда я написал URL-адрес http://"mydomain"/admin/health или http://"mydomain"/health, мое приложение ничего не получает.
@Component
public class DBHealthIndicator extends AbstractHealthIndicator {
private final AccountsService accountsService;
@Autowired
public DBHealthIndicator(AccountsService accountsService) {
if (accountsService == null) {
throw new IllegalArgumentException(
"An AccountsService is mandatory.");
}
this.accountsService = accountsService;
}
@Override
protected void doHealthCheck(Builder builder) throws Exception {
if (accountsService.getAccounts(1, 1)!= null){
builder.up();
}else{
builder.down();
}
}
}
Кто-нибудь может мне помочь?
Спасибо
Обновление:
Вот мой application.yml
server: servlet-path: /api port: 8080
mongodb: host: conexion port: 27017 databaseName: abc #uri: conexion
management: context-path: /admin
endpoints: health: enabled: yes shutdown: enabled: yes
logging: # Enable this to specify the path and the name of the log file. By default, it creates a # file named spring.log in the temp directory. file: /tmp/abc.log
level: com.abc: INFO
Подробнее здесь: https://stackoverflow.com/questions/276 ... pring-boot