• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

springboot配置文件抽离 git管理统 配置中心详解

python 搞代码 4年前 (2022-01-08) 28次浏览 已收录 0个评论

在本篇文章里小编给大家整理的是关于springboot配置文件抽离 git管理统 配置中心的相关知识点内容,有需要的朋友们可以学习下。

springboot配置文件抽离,便于服务器读取对应配置文件,避免项目频繁更改配置文件,影响项目的调试与发布

1.创建统一配置中心项目conifg

1)pom配置依赖

  org.springframework.bootspring-boot-starter-parent2.0.6.RELEASE<!-- lookup parent from repository --> UTF-8UTF-81.8Finchley.SR2  org.springframework.cloudspring-cloud-config-server org.springframework.cloudspring-cloud-starter-netflix-eureka-client org.springframework.bootspring-boot-starter-testtest org.springframework.cloudspring-cloud-starter-bus-amqp org.springframework.cloudspring-cloud-config-monitor   org.springframework.cloudspring-cloud-dependencies${spring-cloud.version}pomimport

2)yml文件配置

 spring: application: name: config cloud: config: server: git: uri: https://gitee.com/XXXX/XXXXXX.git username: XXXXXXX password: XXXXXXXXX eureka: client: service-url: defaultZone: http://localhost:8000/eureka/ management: endpoints: web: expose: "*"

2.创建git私有项目config-repo 用于存放配置文件

3.配置项目 可以看到对应的配置文件内容

http://localhost:8002/XXXXX/user-dev.yml

4来源gaodai#ma#com搞@@代~&码网.配置客户端读取配置文件

1)客户端配置pom

  org.springframework.cloudspring-cloud-config-client

2)客户端yml文件配置

 spring: application: name: XXXXXX cloud: config: discovery: enabled: true service-id: CONFIG profile: dev eureka: client: service-url: defaultZone: http://localhost:8000/eureka/ instance: prefer-ip-address: true lease-renewal-interval-in-seconds: 1 # 单机时关闭eureka 保护模式 lease-expiration-duration-in-seconds: 2

以上就是springboot配置文件抽离 git管理统 配置中心详解的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:springboot配置文件抽离 git管理统 配置中心详解

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址