## springCloud config refresh刷新actuator踩坑

本文详细介绍了Spring Boot中Actuator组件的使用方法,包括如何通过配置启用Actuator的功能,如health和info检查,以及如何在不同版本中进行刷新操作。特别针对2.0以后版本的配置变化进行了说明,并提供了具体的curl命令示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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-actuator

2 加配置(敲黑板

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
在这里插入图片描述
纯手打请给与支持

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值