【问题标题】:Spring cloud, config server can not start, how to config uri for gitSpring Cloud,配置服务器无法启动,如何为git配置uri
【发布时间】:2015-06-02 00:00:32
【问题描述】:

我对spring cloud项目很感兴趣,现在正在测试,但立即被屏蔽了。

  1. 在 POM 中:我添加了这个依赖项:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>
  1. 对于主要应用:
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
public class SpringConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringConfigServerApplication.class, args);
    }
}  

所以根据文档,我只需要添加enableConfigServer,然后我尝试启动它,这是错误:

org.springframework.beans.factory.BeanCreationException:创建类 org.springframework.cloud.config.server.ConfigServerConfiguration$GitRepositoryConfiguration 中定义的名称为“environmentRepository”的 bean 时出错:调用 init 方法失败;嵌套异常是 java.lang.IllegalStateException: 你需要为 git 仓库配置一个 uri

那么,如何为 git 存储库配置 uri?文档中没有提到任何内容。

感谢您的详细说明

【问题讨论】:

  • 您可以在 application.yml 中将其称为 spring.cloud.config.server.git.uri。即使我试图抓住这个主题,这个资源对我帮助很大,你也应该尝试一下[Spring-Cloud Sample]qiita.com/making@github/items/…

标签: git spring-cloud spring-cloud-config


【解决方案1】:

我遇到了同样的问题,当我在 application.yml 文件中设置配置文件时,它已解决,如下所示:

spring:  
 profiles:   
  active: native

【讨论】:

    【解决方案2】:

    关于这个严重的问题,您需要做的就是清理您的 maven 存储库并再次更新它。这对我有用!

    【讨论】:

    • 请通过添加有关问题解决方案的更多信息来增强您的答案
    【解决方案3】:

    我们的例子是here。来自application.ymlconfiguration 如下所示:

    spring:
      cloud:
        config:
          server:
            git:
              uri: https://github.com/spring-cloud-samples/config-repo
    

    【讨论】:

    • 感谢您提供此信息。但我有一个问题,它只从存储库获取主分支,而不是基于配置文件的开发或其他。我们如何指定配置文件特定的 git uri 和分支?
    • 好的,我知道了。它基本上是 label ,我必须在 uri 下设置,并且由于配置服务器已经打开资源,例如 /{label}/{name}-{profiles}.yml,默认情况下标签会按照文档转到 master。
    • @spencergibb 因此,为了添加加密/解密机制,我在类路径中添加了密钥库 [*.jsk],但由于依赖关系不满足而无法启动应用程序。我添加了 rsa 依赖项,但仍然看到相同的错误。你能发表评论还是我应该把它当作一个新问题?
    • 这里有任何快速帮助 - 原因:org.eclipse.jgit.api.errors.RefNotFoundException: Ref master cannot be resolve?
    猜你喜欢
    • 2018-08-24
    • 2019-05-15
    • 2017-09-07
    • 2017-07-25
    • 2023-03-24
    • 1970-01-01
    • 2019-11-26
    • 2018-04-14
    • 1970-01-01
    相关资源
    最近更新 更多