简体   繁体   English

如何编写带有Spring Boot(1.5.3.RELEASE)和Spring Cloud Config(1.3.0.RELEASE)的Spring Cloud Config服务器?

[英]How do you write a Spring Cloud Config Server with Spring Boot (1.5.3.RELEASE) and Spring Cloud Config (1.3.0.RELEASE)?

I modified the spring-cloud-config-server-mongodb project to use the latest version of Spring Boot (1.5.3.RELEASE) and Spring Cloud Config (1.3.0.RELEASE). 我修改了spring-cloud-config-server-mongodb项目,以使用最新版本的Spring Boot(1.5.3.RELEASE)和Spring Cloud Config(1.3.0.RELEASE)。 I also introduced the class MongoConfigServer that runs the mongo db config server. 我还介绍了运行mongo db配置服务器的MongoConfigServer类。

When I run it, I get this error: 运行它时,出现以下错误:

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.config.server.environment.EnvironmentRepository' available: more than one 'primary' bean found among candidates: [searchPathLocator, environmentRepository, searchPathCompositeEnvironmentRepository]

I am not sure what I did wrong. 我不确定自己做错了什么。 How do I write my own config server without getting this error? 如何编写自己的配置服务器而不会出现此错误? I don't see any documentation on how to do this. 我没有任何有关如何执行此操作的文档。

Can somebody please help me, or guide me? 有人可以帮我还是指导我?

This mongo db config server used to work with older versions of Spring Boot and Spring Cloud Config. 该mongo db config服务器用于与旧版本的Spring Boot和Spring Cloud Config一起使用。 I am using this Mongo DB Config Server as an example for writing a different Config Server, which is also receiving the same error. 我使用此Mongo DB Config Server作为编写其他Config Server的示例,该服务器也收到相同的错误。

My fork of spring-cloud-config-server-mongodb is available at https://github.com/minmay/spring-cloud-config-server-mongodb.git 我的spring-cloud-config-server-mongodb分支可以在https://github.com/minmay/spring-cloud-config-server-mongodb.git上找到。

spring-cloud-config-server-mongodb项目已升级为使用spring-boot 1.5.7快照。

I fixed this issue by updating https://github.com/minmay/spring-cloud-config-server-mongodb/blob/master/src/main/java/org/springframework/cloud/config/server/mongodb/config/MongoEnvironmentRepositoryConfiguration.java . 我通过更新https://github.com/minmay/spring-cloud-config-server-mongodb/blob/master/src/main/java/org/springframework/cloud/config/server/mongodb/config/来解决此问题MongoEnvironmentRepositoryConfiguration.java

What I did was I removed the searchPathLocator bean, and removed the primary annotation from environmentRepository. 我要做的是删除了searchPathLocator bean,并从environmentRepository中删除了主要注释。

I guess Spring Cloud Config was updated to conditionally find an environmentRepository bean. 我猜想Spring Cloud Config已更新为有条件地找到一个environmentRepository bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM