1.项目中使用的maven插件对依赖包进行管理,在pom文件中需要添加配置,用来加载配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2.导致借口访问失败的原因
spring-boot 1.0 版本能够正常访问
spring-boot 2.0 版本当中,作为安全性考虑,将actuator 控件中的端口,只默认开放/health 和/info 两个端口,其他端口默认关闭。当你需要使用气短监控端口时,需要手动在application.properties 文件中添加配置。配置形式为 management.endpoints.web.exposure.include=xxx 开启xxx端口的访问 , 如果去掉所有的端口访问限制,则配置形式为
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.include=env
management.endpoints.web.exposure.include=*
2.0以上版本中,除了提供了开启某个端口的访问配置之外,还提供了关闭某个端口到的访问配置形式为
management.endpoints.web.exposure.exclude=xxx,xxx
management.endpoints.web.exposure.exclude=env,beans
2.0中还有一个变动,所有的端口 默认访问形式都是 actuator/XXX 例如actuator/health。