config /actuator/bus-refresh Request method 'POST' not supported

本文详细解析了在Spring Cloud Config Server中遇到的配置刷新问题,包括错误处理、依赖检查及正确配置actuator端点的方法。通过调整management.endpoints.web.exposure.include属性,确保bus-refresh端点可用,实现配置的自动刷新。

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

spring cloud config server 实现 刷新配置的 时候 爆的错

下来版本

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.6.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<spring-cloud.version>Finchley.SR2</spring-cloud.version>
	</properties>

然后 使用post 请求config server : localhost:9090/actuator/bus-refresh

就出现了/actuator/bus-refresh Request method 'POST' not supported

然后我试着用 get 请求 

{"name":"actuator","profiles":["bus-refresh"],"label":null,"version":"e6e2d67a2a78e8d62649cce2b62609f395c0ef9c","state":null,"propertySources":[]}

发现配置更新依然没有起作用

但是发现 config  server 是有 依赖  引入 actuator 包的

参考 https://357029540.iteye.com/blog/2432558

https://blog.csdn.net/hnsftqs/article/details/80801072

原来的 配置 不一样了

management:
  endpoints:  # 暴露bus 接口 ,否则 更新 refresh 没用的
    web:
      exposure:    # expose: "*" 已过期
        include: "*"
  endpoint:
    bus-refresh:
      enabled: true

 

OK, 重启服务之后, 通过 日志可以发现 /actuator/bus-refresh 已经变为 post 请求方式了,执行

就发现 confing  client  会自动 reload 的。

不用 加 @RefreshScope 也是会 自动刷新配置的

 

 

转载于:https://my.oschina.net/ouminzy/blog/3085703

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值