Я хотел бы иметь индикатор здоровья в моей конфигурации o пружинной загрузки. Но я не справился с этим.
У меня есть следующий класс, с @component, но когда я написал 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();
}
}
}
< /code>
anyboyd может мне помочь?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