服务端 ConfigServer

pom.xml添加config jar

		<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

添加EnableConfigServer

@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}

application.yml

server:
port: ${PORT:8888} #配置工程端口号 spring:
application:
name: common-config-server #设置该服务应用名称
profiles:
active: native #设置读取为本地工程文件
config:
server:
native:
searchLocations: classpath:/config #配置文件根目录,也就是XXX-dev.properties等的目录

官网也用发发发发这个端口。

配置文件

config下新建配置文件:

XXX-dev.properties

XXX-test.properties

客户端AppClient

pom.xml

	<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>

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

参考资料:

csdn blog

最新文章

  1. PHP的pcntl多进程
  2. Xen启动过程分析(还是分享过来吧,找了好长时间)
  3. 山东省滕州市木石镇化石沟村QQ群116528924
  4. 解决ASP.Net第一次访问慢的处理(IIS8)
  5. TJI读书笔记15-持有对象
  6. 微分方程&mdash;&mdash;基本概念和常微分方程的发展史
  7. Java爬虫工程师技能列表
  8. php和AJAX用户注册演示程序
  9. 配置IISExpress允许外部访问
  10. ExtJS 添加图标icon
  11. 完美解决 未能打开编辑器:Unmatched braces in the pattern.
  12. 高质量程序设计指南C/C++语言——内存管理
  13. Natas Wargame Level 13 Writeup(文件上传漏洞,篡改file signature,Exif)
  14. 如何在你的blog中添加炫酷的飘雪动画效果
  15. spring boot整合mybatis方式一
  16. Vue 组件&amp;组件之间的通信 之 使用slot分发内容
  17. Feign 自定义编码器、解码器和客户端
  18. JavaScript:new function(){}和function(){}()
  19. alibaba/Sentinel 分布式 系统流量防卫兵
  20. spark内存管理分析

热门文章

  1. bzoj 1413 [ZJOI2009]取石子游戏
  2. DEA中MAVEN项目有多个子目录,如何加载构建
  3. DOM节点是啥玩意?
  4. Codeforces 799E(贪心)
  5. Ubuntu 16.04出现Can&#39;t open /etc/rc.d/init.d/functions的问题解决
  6. MongoDB小结15 - find【查询条件$ne】
  7. openWrt 安装管理界面luci中文包
  8. sh变更权限
  9. 移动硬盘/U盘上装Windows 7旗舰版(VHD版)
  10. 1064 - You have an error in your SQL syntax问题解决