[英]Spring cloud, config server can not start, how to config uri for git
I am pretty interested in spring cloud project and now I am testing it, but blocked immediately.我对 Spring Cloud 项目很感兴趣,现在我正在测试它,但立即被阻止。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
@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;
org.springframework.beans.factory.BeanCreationException:创建类 org.springframework.cloud.config.server.ConfigServerConfiguration$GitRepositoryConfiguration 中定义的名称为“environmentRepository”的 bean 时出错:调用 init 方法失败; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository
嵌套异常是 java.lang.IllegalStateException: 您需要为 git 存储库配置一个 uri
So, how can I config a uri for git repository?那么,如何为 git 存储库配置 uri? There is nothing mentioned in the documentation.
文档中没有提到任何内容。
Thanks for more clarification感谢您的更多澄清
Our example is here .我们的例子在这里。 The configuration from
application.yml
looks like this: application.yml
的配置如下所示:
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
I had the same issue and it was resolved when I set the profile in application.yml file as below:我遇到了同样的问题,当我在 application.yml 文件中设置配置文件时它得到了解决,如下所示:
spring:
profiles:
active: native
Adding this solves issue添加这个可以解决问题
in yml在 yml
spring:
cloud:
config:
server:
git:
uri: https://github.com/user/microservices-central-config-repourl.git
clone-on-start: true
default-label: main
OR或者
in property file在属性文件中
spring.cloud.config.server.git.default-label=main
About this serious problem, all you need to do is clean your maven repository and update it one again.关于这个严重的问题,您需要做的就是清理您的 Maven 存储库并再次更新它。 That's worked for me !!
这对我有用!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.