【问题标题】:Spring Cloud Config Server Can't locate PropertySource on startupSpring Cloud Config Server 启动时找不到 PropertySource
【发布时间】:2015-04-07 03:57:09
【问题描述】:

当我启动 Spring Cloud Config Server 时,出现以下错误。

Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/configserver/default/master":Connection refused; nested exception is java.net.ConnectException: Connection refused

但是,当我在浏览器中点击该 URL 时,它存在并且配置服务器正在运行。怎么回事?

application.yml

server:
  port: 8888
management:
  context-path: /admin
logging:
  level:
    com.netflix.discovery: 'OFF'
    org.springframework.cloud: 'DEBUG'
spring:
  cloud:
    config:
      server:
        git:
          uri: file:/home/dev/configs     

bootstrap.yml

spring:
  application:
    name: configserver

【问题讨论】:

    标签: spring-boot spring-cloud


    【解决方案1】:

    如果您的配置服务器也不打算成为配置客户端,您需要设置 spring.cloud.config.enabled=false 以避免该日志条目(尽管它是无害的)。

    【讨论】:

    • 感谢您的回答。还有一个问题。如果该配置存在,那么为什么我会在启动时收到错误消息?我希望配置服务器也是客户端。
    • 你的意思是你想让它从它的存储库中加载它自己的属性?试试spring.cloud.config.server.bootstrap=true
    • 当我输入spring.cloud.config.enabled=false 时,错误消失了,但这意味着它没有从存储库中读取。如果我在存储库中有 application.yml 和 configserver.yml 配置服务器是否可以从存储库中读取并在启动时使用这些值(如果它是唯一的配置服务器)?抱歉,我并不清楚我想弄清楚什么。
    • 你有没有试过spring.cloud.config.server.bootstrap=true
    • 通过设置spring.cloud.config.server.bootstrap=true(在bootstrap.yml中)。
    【解决方案2】:

    bootstrap yml 文件中的 eureka.client.serviceUrl.defaultZone 和 spring.cloud.config.* 配置

    【讨论】:

    • 您可以将代码添加到帖子中,而不是图像吗?
    【解决方案3】:

    当您的一项服务无法连接到云配置服务器时,会显示此错误。 为了使它工作。我假设您正在使用 STS 或任何 Eclipse 环境,运行您的 cloud-config 服务器应用程序,然后运行其配置存储在 cloud-config 中的其他服务。保持运行这两个服务非常重要。 其他需要注意的预防措施是:应用程序的 application.properties 文件应重命名为 bootstrap.properties' 并且端口不应被任何其他服务使用

    【讨论】:

      猜你喜欢
      • 2019-10-07
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 2019-03-02
      • 2020-11-01
      • 2020-06-03
      • 2016-06-04
      • 2017-10-16
      相关资源
      最近更新 更多