spring cloud config搭建说明例子(一)-简单示例
2024-09-03 17:28:02
服务端 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
最新文章
- PHP的pcntl多进程
- Xen启动过程分析(还是分享过来吧,找了好长时间)
- 山东省滕州市木石镇化石沟村QQ群116528924
- 解决ASP.Net第一次访问慢的处理(IIS8)
- TJI读书笔记15-持有对象
- 微分方程&mdash;&mdash;基本概念和常微分方程的发展史
- Java爬虫工程师技能列表
- php和AJAX用户注册演示程序
- 配置IISExpress允许外部访问
- ExtJS 添加图标icon
- 完美解决 未能打开编辑器:Unmatched braces in the pattern.
- 高质量程序设计指南C/C++语言——内存管理
- Natas Wargame Level 13 Writeup(文件上传漏洞,篡改file signature,Exif)
- 如何在你的blog中添加炫酷的飘雪动画效果
- spring boot整合mybatis方式一
- Vue 组件&;组件之间的通信 之 使用slot分发内容
- Feign 自定义编码器、解码器和客户端
- JavaScript:new function(){}和function(){}()
- alibaba/Sentinel 分布式 系统流量防卫兵
- spark内存管理分析
热门文章
- bzoj 1413 [ZJOI2009]取石子游戏
- DEA中MAVEN项目有多个子目录,如何加载构建
- DOM节点是啥玩意?
- Codeforces 799E(贪心)
- Ubuntu 16.04出现Can&#39;t open /etc/rc.d/init.d/functions的问题解决
- MongoDB小结15 - find【查询条件$ne】
- openWrt 安装管理界面luci中文包
- sh变更权限
- 移动硬盘/U盘上装Windows 7旗舰版(VHD版)
- 1064 - You have an error in your SQL syntax问题解决