Config server
来源:互联网 发布:苹果mac键盘鼠标失灵 编辑:程序博客网 时间:2024/05/22 04:27
一、安装rebbitmq
1.下载安装
2.ip和端口
1) mq后台配置:localhost:5672
2) mq管理界面:localhost:15672
注:管理界面是一个插件,不会自动安装。
安装插件命令:rabbitmq-plugins enable rabbitmq_management
二、服务端config-server配置
1.pom.xml添加配置:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
2.application.yml配置mq:
spring: application: name: config-server # 项目名称尽量用小写 cloud: config: server: git: uri: https://git.oschina.net/ruihin/xms/ # 配置git仓库的地址 search-paths: config-repository # git仓库地址下的相对地址,可以配置多个,用,分割。 username: # git仓库的账号 password: # git仓库的密码 bus: trace: enabled: true # 开启cloud bus的跟踪 rabbitmq: host: 10.83.20.167 port: 5672 username: guest password: guest
3.**Application.java类前添加:@EnableConfigServer
三、客户端config-client配置
1.pom.xml配置:
<!-- Spring-boot 执行器:Spring-boot自带的监控模块 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 整合配置文件 config-server --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <!-- 自动更新配置文件的 MQ --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency>
2.application.yml配置mq:
spring: cloud: config: uri: http://10.83.3.13:8040/ profile: dev # 指定profile,对应config-repository中文件名的后缀{profile} label: master # 指定git仓库的分支,对应config-server所获取的配置文件的{label} rabbitmq: host: 10.83.20.167 port: 5672 username: guest password: guest management: #springboot 1.5.X 以上默认开通了安全认证,需要改为false,否则更新curl -X POST http://localhost:8001/refresh时,会报401没权限 security: enabled: false
3.使用配置文件参数的service或controller:添加@RefreshScope
@RestController@RequestMapping("/user")@RefreshScopepublic class ProviderUserController { @Value("${profile}") private String profile; @GetMapping("/hello") public String hello() { return this.profile; }}
四、更新操作
1.修改.properties文件并git提交
2.触发配置更新操作
1)方式一(适于开发期):执行shell 或命令
命令:curl -X POST http://localhost:8001/refresh
或是shell:
chmod +x /Users/XHZ/Ruihin/test/RefreshConfigClient.sh
./Ruihin/test/RefreshConfigClient.sh
2)在webhook上配置:
a.http://localhost:8001/refresh
注:localhost改成config-client的外网地址
b.勾选:push和tag push
c.提交
阅读全文
0 0
- Config server
- config-server
- VNC Server config
- Ubuntu synergy server config
- Apache Server Inst&Config.
- ubuntu config FTP Server
- ssh-server-config
- Jasper server Config document
- 03-SSH server config
- Spring Cloud Config Server
- Axis soap server-config.wsdd
- Sql Server web.config ConnectionString
- server config(nginx apache varnish)
- Windows Server Web Deployment Config
- ubuntu server partation config example
- 【SpringBoot】SpringCloud Config Server实践
- mongodb 3.0 Config Server Availability
- spring cloud 之 config-server
- Hibernate初探之一对多映射
- unity3d 生成安卓的keystore修改(安卓工程签名)
- IDEA 安装sliksvn插件
- base64编码转码util
- poj1007DNA Sorting(排序水)
- Config server
- 摩尔斯电码翻译(C++实现)
- sku组合查询算法探索
- ABAP学习笔记三(Internal Table类型)
- SQL必知必会(4)——创建计算字段
- Android音频系统之音频框架
- 常见数据结构与算法整理总结
- system函数返回(如何判断调用的shell命令是否执行成功)
- Windows下WebStorm配置使用SVN详细过程(客户端和服务端完整版)