遇到的问题
修改Github上配置文件后,通过curl -X POST "http://localhost:3344/actuator/bus-refresh"来进行动态刷新全局广播就会报405(这里的刷新路径是本地路径,具体的可根据实际项目地址来配) 原来的配置中心服务端的配置文件(application.yml)如下:
server:
port: 3344
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: https://github.com.cnpmjs.org/******/springcloud-config.git
search-paths:
- springcloud-config
label: main
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
management:
endpoints:
web:
exposure:
include: "bus-refresh"
解决办法
试了好多解决办法,最后发现是config的服务端没有指定从github拉取配置文件的放置路径,而这样就会放到系统(windows)默认的路径下,而项目在使用的时候又没法获取,所以导致全局广播报错 需要新加: basedir: F:/learnjava/spring_cloud/2021/springcloud-config # 具体路径根据自己放的地址来配 修改配置中心的配置文件如下:
server:
port: 3344
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: https://github.com.cnpmjs.org/******/springcloud-config.git
search-paths:
- springcloud-config
basedir: F:/learnjava/spring_cloud/2021/springcloud-config
label: main
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
修改Github上配置文件
management:
endpoints:
web:
exposure:
include: "bus-refresh"
小结
这个问题花费了不少时间来解决,不过同样的问题可能导致的原因不同,仅供参考!
|