依赖
<!-- 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
该文章介绍了如何在SpringBoot应用中添加监控依赖,如`spring-boot-starter-actuator`和`spring-boot-starter-web`。通过配置`application.yml`,设置监控HTTP端口,控制endpoint的暴露,例如排除`health.mail`检查,启用shutdown并设定基础路径。同时,配置了CORS允许的方法和JMX的exposure,以及服务器端口和安全管理,限制远程管理连接。

被折叠的 条评论
为什么被折叠?



