跟着周阳老师学Springcloud,在跟着敲config时,所有代码都跟周洋老师一模一样,在模拟配置工程师通过命令行发送POST请求刷新3355的时候,发现问题如下:

{“timestamp”:“2022-03-25T12:40:38.852+0000”,“status”:404,“error”:“Not Found”,“message”:“No message available”,“path”:"/actuator/refresh"}

在这里插入图片描述
这个后面查资料说3355的bootstrap.yml缺少配置
需要添加这些东西:

management:  #actuator
  server:
    port: 3355
  endpoints:
    web:
      #      base-path: / #默认是/actuator 前缀,可以在这里修改
      exposure:
        include: "*"  #打开全部请求端点
#        include: refresh,health,info #打开部分

修改前是这样:

server:
  port: 3355

spring:
  application:
    name: config-client
  cloud:
    #Config客户端配置
    config:
      label: master #分支名称
      name: config #配置文件名称
      profile: dev #读取后缀名称   上述3个综合:master分支上config-dev.yml的配置文件被读取http://config-3344.com:3344/master/config-dev.yml
      uri: http://localhost:3344 #配置中心地址k

#服务注册到eureka地址
eureka:
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka

修改之后是这样:

server:
  port: 3355

spring:
  application:
    name: config-client
  cloud:
    #Config客户端配置
    config:
      label: master #分支名称
      name: config #配置文件名称
      profile: dev #读取后缀名称   上述3个综合:master分支上config-dev.yml的配置文件被读取http://config-3344.com:3344/master/config-dev.yml
      uri: http://localhost:3344 #配置中心地址k

#服务注册到eureka地址
eureka:
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka

management:  #actuator
  server:
    port: 3355
  endpoints:
    web:
      #      base-path: / #默认是/actuator 前缀,可以在这里修改
      exposure:
        include: "*"  #打开全部请求端点
#        include: refresh,health,info #打开部分

修改之后运行结果:
在这里插入图片描述

这样就OK啦,但是我看到周阳老师的视频里面并没有添加这些东西,有碰到同样问题的阳粉吗?欢迎留言。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐