【问题标题】:Spring boot Could not locate PropertySource: label not foundSpring boot 找不到 PropertySource:标签未找到
【发布时间】:2017-10-16 07:27:17
【问题描述】:

我正在尝试设置 Spring Cloud Config Server,但是服务配置服务器,它在端口 8888 上运行是正确的,另一个服务应该在端口 18060 上运行,但是由于我启动时的原因,它为我分配端口 8080并返回警告“无法找到 PropertySource:未找到标签”,我该怎么办?谢谢!!!

【问题讨论】:

  • 看看这个question它可能会有所帮助
  • 试过了,还是不行
  • @JosephT 。你能解决这个问题吗?我也面临同样的问题。
  • 我遇到了同样的问题。原来配置服务器尚未配置存储库。填写默认配置并重新暂存后,应用列出标签并加载属性文件。

标签: java spring maven spring-boot


【解决方案1】:

在spring boot应用的配置类级别或主类添加@EnableConfigServer,重启服务即可。

【讨论】:

  • 天哪,我不敢相信我忘记了这个......谢谢!
【解决方案2】:

我遇到了类似的问题,当我在本地运行我的服务器时,我只在 stratup 上的日志中看到

o.s.c.c.c.ConfigServicePropertySourceLocator - Could not locate PropertySource: label not found

原来这是配置服务器的健康检查问题,当健康检查被触发到配置服务器时,使用了一个空环境,因此应用程序名称为空,因此 Spring Cloud 客户端将尝试访问 {config- server}/application 因为应用程序是默认应用程序名称,请参阅issue 了解更多信息。

为了解决这个问题,我刚刚禁用了配置服务器的健康检查

health.config.enabled=false

【讨论】:

    【解决方案3】:

    在我的情况下,这是因为我必须通过将以下设置为应用程序.properties

    spring.cloud.config.server.git.default-label=main
    

    【讨论】:

      【解决方案4】:

      试试这个。我有同样的问题并解决了。

      首先在您的应用程序中启用调试模式。(在您的属性文件中:logging.level.=DEBUG。这只是为了确保问题与我的相同,或者您可能知道它可能出错的地方。) 然后启动应用程序并查看日志。日志显示配置的服务器 URI 以及获取所有属性资源的 URL
      比较两个 URL - 日志中的一个和您的配置服务器 URI。
      问题是错误地定义属性文件的 URL 可以在末尾有空格。 (当您从某处复制过去时可能会发生这种情况)示例:
      spring.cloud.config.uri=http:localhost 的值:

      如果是这种情况,客户端的日志显示localhost:/20%20%//

      只需删除帖子的空白空间。那么它应该可以工作了!

      【讨论】:

        【解决方案5】:

        在您的 bootstrap.yml 文件中 添加这些行

        spring:
          cloud:
            config:
              enabled: true
              uri: http://localhost:8888 ##this is the link to the server config
              label: main ##this is what you are missing (name of the git repo branch)
          application:
            name: currency-spring-cloud-config-client
          profiles:
            active: testing
        
        
        server:
          port: 8600
        

        【讨论】:

          【解决方案6】:
          spring:
            cloud:
              config:
                enabled: true
                uri:
                  - http://localhost:9196   ### your port for cloud config server
                label: main                 ### your git repo branch name
          

          【讨论】:

          • 这假设您首先使用配置服务器进行配置而不是先发现
          猜你喜欢
          • 2016-09-02
          • 2018-01-22
          • 2021-06-24
          • 2015-04-07
          • 2021-05-31
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-06-23
          相关资源
          最近更新 更多