首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Cloud Config over Spring Cloud Config

Spring Cloud Config over Spring Cloud Config
EN

Stack Overflow用户
提问于 2015-11-17 12:12:47
回答 2查看 8.4K关注 0票数 16

我真的很难接受这一点。我们想使用Spring Cloud Consul进行服务发现,我的学院正在推动使用Spring Cloud Config over Spring Cloud Config的想法,我之前已经在相关项目中实现了这一想法。问题是,Spring Cloud Config工作得很好,并且有一个无缝的开箱即用的版本控制管道(git)来实现属性的动态集中管理。为了在Spring Cloud Consul Config中支持相同的功能,似乎需要重新发明已经在Spring Cloud Config中烘焙的轮子。

有谁有使用这两种方法的经验吗?将两者一起使用是否有意义?也就是说,让Spring Cloud Config Client指向Spring Cloud Config Server以获取更多的“静态”环境属性(开发、质量、阶段、生产之间的变化,否则都是静态的),并将Spring Cloud Consul Config指向纯动态属性,如服务发现?

如果我错了,请有人纠正我,但根据我的理解,为了使用Spring Cloud Config支持“静态”属性的动态版本控制,我需要在git和每个Spring Cloud Config应用程序实例的运行实例的物理"/config“目录之间建立某种管道:/

EN

回答 2

Stack Overflow用户

发布于 2016-09-12 11:50:06

tl;dr:我使用的是spring cloud config和spring cloud consul,而不是spring cloud consul config。

我没有特别使用spring cloud consul config,因为我使用的不是consul config,但我使用的是在consul中注册自己的spring cloud config服务器,并且我有其他微服务通过consul访问spring cloud config服务器以进行服务发现。

下面是我的设置:

春季云配置服务器

依赖关系:

代码语言:javascript
复制
org.springframework.cloud:spring-cloud-config-server
org.springframework.cloud:spring-cloud-starter-consul-discovery
org.springframework.boot:spring-boot-starter-actuator

bootstrap.properties:

代码语言:javascript
复制
spring.application.name=config-server
spring.cloud.consul.host=CONSUL_HOSTNAME
spring.cloud.consul.port=CONSUL_PORT

application.properties:

代码语言:javascript
复制
spring.cloud.config.server.git.uri=GIT_REPO_URL
spring.cloud.config.server.git.username=GIT_REPO_USERNAME
spring.cloud.config.server.git.password=GIT_REPO_PASSWORD

Application.java:

代码语言:javascript
复制
@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
public class Application
{
    public static void main(String[] args)
    {
        SpringApplication.run(Application.class);
    }
}

Spring云客户端应用程序

依赖关系:

代码语言:javascript
复制
org.springframework.cloud:spring-cloud-starter-config
org.springframework.cloud:spring-cloud-starter-consul-discovery
org.springframework.boot:spring-boot-starter-web
org.springframework.boot:spring-boot-starter-actuator

bootstrap.properties:

代码语言:javascript
复制
spring.application.name=client-app-name
spring.cloud.consul.host=CONSUL_HOSTNAME
spring.cloud.consul.port=CONSUL_PORT
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server

Application.java:

代码语言:javascript
复制
@SpringBootApplication
@EnableDiscoveryClient
public class Application
{
    public static void main(String[] args)
    {
        SpringApplication.run(Application.class);
    }
}
票数 7
EN

Stack Overflow用户

发布于 2016-11-30 10:47:45

据我所知,在配置管理方面,与spring cloud config相比,Consul(带有git2Consul)提供了跨多个数据中心的数据交换和节点故障转移的解决方案。

对于单数据中心使用,spring cloud config (简单的故障转移方案,如LVS、主备、rsync机制等)就足够了。

对于服务发现,Consul具有健康检查机制,可以实现路由的自动切换。在spring cloud config中,需要做额外的工作才能实现半自动发现。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33749034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档