欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

springboot配置文件抽離 git管理統(tǒng) 配置中心詳解

 更新時(shí)間:2019年09月02日 15:47:47   作者:yu_fly  
在本篇文章里小編給大家整理的是關(guān)于springboot配置文件抽離 git管理統(tǒng) 配置中心的相關(guān)知識(shí)點(diǎn)內(nèi)容,有需要的朋友們可以學(xué)習(xí)下。

springboot配置文件抽離,便于服務(wù)器讀取對(duì)應(yīng)配置文件,避免項(xiàng)目頻繁更改配置文件,影響項(xiàng)目的調(diào)試與發(fā)布

1.創(chuàng)建統(tǒng)一配置中心項(xiàng)目conifg

1)pom配置依賴

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.6.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  <java.version>1.8</java.version>
  <spring-cloud.version>Finchley.SR2</spring-cloud.version>
</properties>

<dependencies>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  </dependency>

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
  </dependency>

  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-bus-amqp</artifactId>
  </dependency>

  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-monitor</artifactId>
  </dependency>
</dependencies>

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>${spring-cloud.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

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.創(chuàng)建git私有項(xiàng)目config-repo 用于存放配置文件

3.配置項(xiàng)目 可以看到對(duì)應(yīng)的配置文件內(nèi)容

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

4.配置客戶端讀取配置文件

1)客戶端配置pom

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-client</artifactId>
</dependency>

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 # 單機(jī)時(shí)關(guān)閉eureka 保護(hù)模式
  lease-expiration-duration-in-seconds: 2

以上就是本次介紹的關(guān)于springboot配置文件抽離 git管理統(tǒng) 配置中心全部知識(shí)點(diǎn)內(nèi)容,感謝大家對(duì)腳本之家的支持。

相關(guān)文章

  • 使用Python進(jìn)行AES加密和解密的示例代碼

    使用Python進(jìn)行AES加密和解密的示例代碼

    這篇文章主要介紹了使用Python進(jìn)行AES加密和解密的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-02-02
  • PHP基于phpqrcode類庫生成二維碼過程解析

    PHP基于phpqrcode類庫生成二維碼過程解析

    這篇文章主要介紹了PHP基于phpqrcode類庫生成二維碼過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • 解讀python如何實(shí)現(xiàn)決策樹算法

    解讀python如何實(shí)現(xiàn)決策樹算法

    在本篇文章里我們給讀者們分享了關(guān)于python如何實(shí)現(xiàn)決策樹算法的相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們參考下。
    2018-10-10
  • Python3遠(yuǎn)程監(jiān)控程序的實(shí)現(xiàn)方法

    Python3遠(yuǎn)程監(jiān)控程序的實(shí)現(xiàn)方法

    今天小編就為大家分享一篇Python3遠(yuǎn)程監(jiān)控程序的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-07-07
  • Python繪畫好看的星空?qǐng)D

    Python繪畫好看的星空?qǐng)D

    這篇文章主要介紹了Python繪畫好看的星空?qǐng)D,文章內(nèi)容介紹詳細(xì),具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-03-03
  • Python使用Pillow進(jìn)行圖像處理

    Python使用Pillow進(jìn)行圖像處理

    這篇文章介紹了Python使用Pillow進(jìn)行圖像處理的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • numpy的文件存儲(chǔ).npy .npz 文件詳解

    numpy的文件存儲(chǔ).npy .npz 文件詳解

    今天小編就為大家分享一篇numpy的文件存儲(chǔ).npy .npz 文件詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • Python根據(jù)輸入?yún)?shù)計(jì)算結(jié)果的實(shí)例方法

    Python根據(jù)輸入?yún)?shù)計(jì)算結(jié)果的實(shí)例方法

    在本篇文章里小編個(gè)大家整理了一篇關(guān)于Python根據(jù)輸入?yún)?shù)計(jì)算結(jié)果的實(shí)例方法,有興趣的朋友們可以跟著學(xué)習(xí)參考下。
    2021-08-08
  • Python3中的循環(huán)語句示例詳解

    Python3中的循環(huán)語句示例詳解

    這篇文章主要介紹了Python3?循環(huán)語句,本文將詳細(xì)介紹Python3中的循環(huán)語句,給出各種循環(huán)的使用示例,以及運(yùn)行結(jié)果的解釋,需要的朋友可以參考下
    2023-04-04
  • Python hashlib模塊實(shí)例使用詳解

    Python hashlib模塊實(shí)例使用詳解

    這篇文章主要介紹了Python hashlib模塊實(shí)例使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12

最新評(píng)論