依赖
<!-- spring-boot-监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
application.yml中指定监控的HTTP端口(如果不指定,则使用和Server相同的端口);指定去掉某项的检查(比如不监控health.mail):
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
base-path: /actuator
exposure:
exclude:
#include health, info
include: "*"
cors:
allowed-methods: " *"
jmx:
exposure:
include: "*"
server:
# 自定义端口
port: 8080
# 不允许远程管理连接,安全性考虑
address: 127.0.0.1