添加spring-boot-starter-actuator依赖,可以查看应用的监控状态、日志级别、请求mapping等配置,使用步骤如下
1、修改pom文件
在pom文件中添加下面依赖(注意:因为在父工程中管理了版本信息,所以moudle没有指定版本号)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、application.yaml添加配置
这里只给出了部分测试配置,注意在生产环境中安全问题,不暴露敏感信息
management:
endpoints:
web:
exposure:
include: mappings,health,info
3、测试
浏览器访问:http://localhost/actuator
返回结果:
{
"_links": {
"self": {
"href": "http://localhost/actuator",
"templated": false
},
"health": {
"href": "http://localhost/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost/actuator/info",
"templated": false
},
"mappings": {
"href": "http://localhost/actuator/mappings",
"templated": false
}
}
}
测试访问mapping