crear un properties local + implementar actuator/health

 1) en pom.xml

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-actuator</artifactId>

</dependency>


2) crear application-local.properties
y agregar:

management.endpoints.web.exposure.include=health
management.endpoint.health.show-details=always

3 SecurityConfig exige autenticación para anyRequest(), por eso /actuator/health puede rechazarse. Permite explícitamente el endpoint de health

// ...existing code...
                .authorizeHttpRequests(authz -> authz
                        .requestMatchers("/api/auth/**", "/api/usuarios/registrar").permitAll()
                        .requestMatchers("/actuator/health").permitAll() // <-- permitir health
                        .requestMatchers("/api/empleados/**").hasRole(TipoUsuarioEnum.ADMINISTRADOR.name())
                        // ...existing code...

4)
ejecutar la aplicacion seteando el environment como LOCAL

mvn spring-boot:run -Dspring-boot.run.profiles=local

5) en el browser probar:

http://localhost:8081/actuator/health

deberia mostrarse:

{
"status": "UP"
}


Comentarios

Entradas populares de este blog

subir un proyecto local a un repositorio de github