关于spring cloud config
来源:互联网 发布:网络公会如何纳税 编辑:程序博客网 时间:2024/04/28 09:42
好记性不如乱笔头 以后掌握了一些东西一定要写下来 这样才不会忘,忘的话回过头的来一下还能记的清楚
两周之前尝试spring cloud config的配置 对于一些东西已经有了初步的了解 但是今天回过头的时候竟然发现忘记的差不多了
所以只能再尝试一些配置 并将其记录下来
在配置之前先要说一下spring boot加载配置文件的顺序的
先去找目录下的bootstrap.yaml配置,然后再去读取config-server 提供的配置文件,再读取本地的applcation.yaml配置文件
读取config-server提供的配置文件匹配规则为
/{application}/{profile}[/{label}]/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
- application:表示应用名称,在client中通过
spring.config.name
配置 - profile:表示获取指定环境下配置,例如开发环境、测试环境、生产环境 默认值default,实际开发中可以是 dev、test、demo、production等
- label: git标签,默认值master
客户端从git 读取的优先顺序为 先去找 application-profile 文件 如果有即读该文件的配置 如果没有就去找application 文件中的 profile
1.config-server 服务配置
添加@EnableConfigServer 注解
@SpringBootApplication@EnableConfigServer //1@EnableEurekaClient //2public class ConfigApplication { public static void main(String[] args) { SpringApplication.run(ConfigApplication.class, args); }}
从远程git上面拉取服务
spring: cloud: config: server: git: uri: http://192.168.1.230:8888/r/lihe-configfile.git basedir: target/config从本地拉去配置文件
spring: cloud: config: server: native: search-locations: classpath:/config #12.客户端配置拉取配置文件
spring: profiles.active: dev main.show_banner: false application: name: edgeserver cloud: config: enabled: true #打开从config-server中获取配置文件 name : edgeserver #git中寻找的 配置文件的文件名 如果没有设置此项 默认使用 application.name label: develop #git 分支 uri: http://localhost:8000 #config-server 的地址3.当你到git端修改完配置文件 如果想要该配置文件生效
需要到客户端配置
endpoints: restart.enabled: true refresh.enabled: true到时候只需要到访问 localhost:53739/restart 即可重启服务生效
0 0
- 关于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 Server
- 详解Spring Cloud Config
- Spring Cloud Config
- spring cloud config
- Spring Cloud Config
- Spring Cloud Config (1)
- 蓝牙协议开发常见词汇缩写
- Leetcode-plus-one
- 机器学习 - K近临法(KNN)
- Linux内核多线程(三)
- 比较全面的MySQL优化参考
- 关于spring cloud config
- JavaWeb之Servlet中的response对象
- css实现元素的垂直居中
- 关于生活
- 软件安全性测试
- Logger 最好用的log框架介绍
- C\C++中 fopen中w w+ wb区别:
- mac版安装tomcat的步骤
- Runtime "Apache Tomcat v7.0" is invalid. The specified Tomcat installation directory does not exist.