spring cloud config搭建说明例子(二)-添加eureka
添加注册eureka
服务端 ConfigServer
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
spring-cloud-starter-eureka与spring-cloud-starter-eureka-server的区别?
添加EnableDiscoveryClient
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
@EnableDiscoveryClient与@EnableEurekaClient的区别?
application.yml
server:
port: ${PORT:8888} #配置工程端口号
spring:
application:
name: cloud-config-server #设置该服务应用名称
profiles:
active: native #设置读取为本地工程文件
config:
server:
native:
searchLocations: classpath:/config #配置文件根目录,也就是XXX-dev.properties等的目录
#注册到eureka服务中心进行监控
eureka:
client:
serviceUrl:
defaultZone: http://eureka:eureka@localhost:8761/eureka # 可以逗号分隔,配置多个
官网也用发发发发这个端口。
配置文件
新建配置文件:
XXX-dev.properties
XXX-test.properties
客户端AppClient
pom.xml也需要增加eureka
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
bootstrap.properties配置
spring.cloud.config.name=XXX
spring.cloud.config.profile=dev
#spring.cloud.config.profile=test
spring.cloud.config.uri=http\://localhost\:8888/ # 只能配置一个,不能逗号分隔配置多个config
application.yml配置,和config一样增加eureka
server:
port: 8080 #设置当前服务端口
context-path: /abc #设置服务上下文路径
spring:
application:
name: app-client #service name 设置当前服务名称
eureka:
client:
serviceUrl:
defaultZone: http://eureka:eureka@localhost:8761/eureka # 可以逗号分隔,配置多个
application类增加@EnableEurekaClient
@SpringBootApplication
@EnableEurekaClient
public class ClientApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(ClientApplication.class, args);
}
}
参考资料:
spring cloud config搭建说明例子(一)-简单示例
spring cloud config搭建说明例子(二)-添加eureka的更多相关文章
- spring cloud config搭建说明例子(三)-添加actuator
添加心跳 服务端 ConfigServer pom.xml添加actuator包 <dependency> <groupId>org.springframework.cloud ...
- spring cloud config搭建说明例子(四)-补充配置文件
服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</groupId> ...
- spring cloud config搭建说明例子(一)-简单示例
服务端 ConfigServer pom.xml添加config jar <dependency> <groupId>org.springframework.cloud< ...
- SpringCloud实战之初级入门(三)— spring cloud config搭建git配置中心
目录 1.环境介绍 2.配置中心 2.1 创建工程 2.2 修改配置文件 2.3 在github中加入配置文件 2.3 修改启动文件 3. 访问配置中心 1.环境介绍 上一篇文章中,我们介绍了如何利用 ...
- Spring Cloud Config 搭建Config 服务
配置中心: open API 配置生效监控 一致性的K-V存储 统一配置的实时推送 配置全局恢复.备份.历史版本 高可用集群 通过config 获取配置,流程: 下面介绍,基于spring cloud ...
- Spring Cloud config之一:分布式配置中心入门介绍
Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持.配置服务器为各应用的所有环境提供了一个中心化的外部配置.它实现了对服务端和客户端对Spring Environm ...
- 网络原因导致的 spring cloud config 读取git上的配置文件时报错:Cannot clone or checkout repository
今天在公司使用spring cloud config搭建配置中心的时候,出现了读取不到git库的问题:Cannot clone or checkout repository.在网上百度,前面几个答案都 ...
- Spring Cloud(九)高可用的分布式配置中心 Spring Cloud Config 集成 Eureka 服务
上一篇文章,讲了SpringCloudConfig 集成Git仓库,这一篇我们讲一下SpringCloudConfig 配和 Eureka 注册中心一起使用 在分布式系统中,由于服务数量巨多,为了方便 ...
- spring cloud config配置
参考: http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html http://www.ityouknow ...
随机推荐
- bzoj1052 [HAOI2007]覆盖问题 - 贪心
Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄膜把这些小树遮盖起来,经过一番长久的思考,他决定用3个L*L的正方形塑料薄膜将小 ...
- Ice Cave-CodeForces(广搜)
链接:http://codeforces.com/problemset/problem/540/C You play a computer game. Your character stands on ...
- Warm up-HUD4612(树的直径+Tarjin缩点)
http://acm.hdu.edu.cn/showproblem.php?pid=4612 题目大意:求加一条边最小的桥数 先用Tarjin缩点求出一棵树,然后用bfs求出树的直径,树的直径就是加一 ...
- 动态替换logback FileAppender/RollingFileAppender 配置- Programmatically configure logback FileAppender/RollingBackAppender
一.本文实际解决的问题 如何在代码中修改logback的RollingFileAppender配置(本文代码实例为修改日志文件路径) 二.针对的场景: 本文解决的问题属于一个大需求的一部分,需求为:需 ...
- js转xml时 将xml中不需要的字符替换掉的方法replace()
js中 replace(/\//g, '') 什么作用. 正则表达式 replace(/\//g, '') 的作用是把/替换成''. 用法如下: 比如:var aa= "adsdd/sdsd ...
- 在springBoot与quartz 整合中 @Transaction 失效
问题1::springBoot在与quartz 整合时,使用@Transaction 注解时事务失效 解决方案:创建一个类使用@component被spring管理 ,使用@Transaction标识 ...
- JSP基础教程:tutorialspoint-jsp
来自turorialspoint的JSP基础教程(英文),官网:https://www.tutorialspoint.com/jsp/index.htm 这个教程在国内已经被翻译成中文(不过是属于机器 ...
- 附录A 思科互联网络操作系统(IOS)
思科互联网络操作系统(IOS) 要点 实现IP编址方案和IP服务,以满足中型企业分支机构网络的网络需求 口在路由器上配置和验证 DHCP和DNS 以及排除其故障(包括 CLI/SDM ). 口配置和验 ...
- NYOJ 55 懒省事的小明(哈弗曼树)
懒省事的小明 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描写叙述 小明非常想吃果子,正好果园果子熟了. 在果园里,小明已经将全部的果子打了下来,并且按果子的不 ...
- hbase shell经常使用命令
hbase经常使用命令 /usr/local/cloud/hbase/bin/hbase shell 用shell来连接hbase exit 退出hbase shell version 查看hbase ...