问题
今天需要给一个Spring工程添加健康检查。
pom.xml
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
application.yml
management:endpoints:web:exposure:include: health
只暴露健康检查的接口:{{HOST}}/actuator/health
。
Spring Security配置
放行健康检查的接口,即不需要登录。
requests.antMatchers("/login", "/register", "/captchaImage", "/actuator/**").permitAll()
测试
参考
- Spring Boot Actuator
- Endpoints