refresh刷新不起作用 404 actuator踩坑
Actuator
actuator是springboot中的一个附加功能,官方是对它这样介绍的:
Spring Boot includes a number of additional features to help you monitor and manage your application when you push it to production. You can choose to manage and monitor your application by using HTTP endpoints or with JMX. Auditing, health, and metrics gathering can also be automatically applied to your application.
用法:
1.引入依赖:
Maven方式:
org.springframework.boot spring-boot-starter-actuator2 加配置(敲黑板)
- 2.0之前 直接启动
在启动log日志中,可以看到springboot把一些默认的地址都映射好了,其中我们配置的actuator中health和info已经被映射上了,我们打开地址:http://localhost:8080/actuator/info 或者 http://localhost:8080/actuator/health - 2.0以后
management: #actuator
server:
port: 8081
endpoints:
web:
# base-path: / #默认是/actuator 前缀,可以在这里修改
exposure:
include: "*" #打开全部请求端点
# include: refresh,health,info #打开部分
必须加上启动端口 2.0以后不加上启动端口报404
management: #actuator
server:
port: 8081
3 加注解
@RefreshScope
4 手动刷新(敲黑板,搞了一上午没吃饭)
2.0之前
curl -X POST http://localhost:1031/refresh
curl -X POST “http://localhost:1031/bus/refresh”
2.0之以后
curl -v -X POST “http://localhost:8081/actuator/bus-refresh”
curl -X POST “http://localhost:8081/actuator/bus-refresh”
纯手打请给与支持