spring cloud config 使用
来源:互联网 发布:淘宝网络环境异常 编辑:程序博客网 时间:2024/04/30 10:50
参考:http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html
server
- 创建保存配置文件的git仓库
https://gitee.com/jiyangM/spring-cloud-config/tree/master/config 添加配置文件
server端代码
pox.xml
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency></dependencies>
配置文件application.yml
server: port: 8888spring: cloud: config: server: git: uri: https://gitee.com/jiyangM/spring-cloud-config search-paths: config username: 18600884376@163.com password: 1993Jiyang
/** * Created by jiyang on 15:16 2017/12/15 */@SpringBootApplication@EnableConfigServerpublic class Application { /** * application.java 文件不能直接放在main/java文件夹下,必须要建一个包把他放进去 * @param args */ public static void main(String[] args){ SpringApplication.run(Application.class,args); }}
启动,测试,访问 :
http://localhost:8888/neo-config/test
会返回配置信息。
注意: neo-config/test 对应git仓库中的neo-config-test.yml文件
client
pom.xml
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency></dependencies>
application.yml
spring: application: name: spring-cloud-config-clientserver: port: 8002
bootstrap.yml
spring: cloud: config: name: neo-config profile: dev uri: http://localhost:8888/ label: master
测试类
/** * Created by jiyang on 12:16 2017/12/19 */@RestControllerpublic class HelloController { @Value("${neo.hello}") private String sayHello; @RequestMapping("/hello") public String sayHello(){ return this.sayHello; }}
启动,测试,访问 :http://localhost:8002/hello
阅读全文
0 0
- spring cloud config使用
- spring cloud config 使用
- spring cloud config使用总结
- Spring Cloud Config客户端使用
- spring cloud:spring cloud config
- 使用Spring Cloud Config搭建配置中心
- 使用Spring Cloud Config搭建配置中心
- 使用spring cloud config来统一管理配置文件
- Spring Cloud Config—客户端使用
- 开始Spring Cloud Config
- Spring Cloud Config
- 关于spring cloud config
- Spring Cloud Config
- 开始Spring Cloud Config
- Spring Cloud Config 实践
- Spring Cloud Config
- Spring Cloud Config
- spring cloud config 配置
- 理解Linux系统/etc/init.d目录和/etc/rc.local脚本
- 谷歌分包方案解决64K方法数限制的遗留问题(4.4.4安卓系统的闪退崩溃)
- Android App Not Install. An existing package by the same name with a conflicting signature is alread
- 三道典型C语言题(9)
- jarsigner 应用认领签名
- spring cloud config 使用
- 智能一点
- 解决elasticsearch安装中文分词器
- JAVA总结(基本数据类型)
- 数论——Baby Step Giant Step及扩展算法
- 【Linux】 JDK安装及配置 (tar.gz版)
- Spring boot + Websocket 再篇
- sqlserver的几个分页语句
- Centos 安装JDK之如何下载jdk