git Spring cloud,配置服务器无法启动,如何为git配置uri

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29321338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:51:15  来源:igfitidea点击:

Spring cloud, config server can not start, how to config uri for git

gitspring-cloudspring-cloud-config

提问by user3006967

I am pretty interested in spring cloud project and now I am testing it, but blocked immediately.

我对 spring 云项目很感兴趣,现在我正在测试它,但立即被阻止。

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

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

So based on the documentation, I just need to add enableConfigServer, then I tried to start it, this is the error:

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

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'environmentRepository' defined in class org.springframework.cloud.config.server.ConfigServerConfiguration$GitRepositoryConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository

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

So, how can I config a uri for git repository? There is nothing mentioned in the documentation.

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

Thanks for more clarification

感谢您的更多澄清

回答by spencergibb

Our example is here. The configurationfrom application.ymllooks like this:

我们的例子在这里。来自的配置application.yml如下所示:

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

回答by machal

About this serious problem, all you need to do is clean your maven repository and update it one again. That's worked for me !!

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