8

我对 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?文档中没有提到任何内容。

感谢您的更多澄清

4

3 回答 3

12

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

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
于 2015-03-30T14:06:13.187 回答
3

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

spring:  
 profiles:   
  active: native
于 2021-02-17T13:20:14.567 回答
-3

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

于 2016-07-24T10:19:51.817 回答