内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

SpringCloudConfig入門-創(chuàng)新互聯(lián)

1.    簡(jiǎn)介

創(chuàng)新互聯(lián)專業(yè)IDC數(shù)據(jù)服務(wù)器托管提供商,專業(yè)提供成都服務(wù)器托管,服務(wù)器租用,雅安移動(dòng)機(jī)房雅安移動(dòng)機(jī)房,成都多線服務(wù)器托管等服務(wù)器托管服務(wù)。

Spring Cloud Config 是用來(lái)為分布式系統(tǒng)中為微服務(wù)應(yīng)用提供集中化的外部配置支持,主要分為Spring Cloud Config Server(服務(wù)器端)和Spring Cloud Config Client(客戶端)。

2.    Spring Cloud Config Server

Spring Cloud Config Server為服務(wù)器端,它是一個(gè)單獨(dú)的微服務(wù)應(yīng)用,用來(lái)連接配置倉(cāng)庫(kù)(本文使用的是git倉(cāng)庫(kù))并為客戶端獲取配置信息。

1.     首先,創(chuàng)建config server工程

打開http://start.spring.io/

Spring Cloud Config 入門

填寫好Group、Artifact。選擇依賴的包有Config Server。

對(duì)應(yīng)的pom.xml為

<dependencies>

     <dependency>

         <groupId>org.springframework.cloud</groupId>

         <artifactId>spring-cloud-config-server</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>

2.     將下載下來(lái)的項(xiàng)目導(dǎo)入Eclipse。

目錄結(jié)構(gòu)如下,我這里面新增了bootstrap.yml

Spring Cloud Config 入門

3.     修改配置

在application.yml中添加

      server:

     port: 8080

在bootstrap.yml中添加

spring:

 cloud:

   config:

     server:

       git:

         uri: https://github.com/DevinXin/config-repo

注意:ConfigServerApplication,Spring Boot 啟動(dòng)類上需要添加@EnableConfigServer注解

Spring Cloud Config 入門

4.     啟動(dòng)configServer

通過訪問http://localhost:8080/master/foobar-dev.properties可以讀到git上的配置文件。

Spring Cloud Config 入門

3.    Spring Cloud Config Client

Spring Cloud Config Client為客戶端,客戶端通過配置連接服務(wù)器端,從服務(wù)器端加載配置信息。

1.     創(chuàng)建config client工程

同config server工程創(chuàng)建一樣,依賴需要web,Config Client

對(duì)應(yīng)的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>

2.     修改配置

application.yml配置為

   server:

   port: 8081

bootstrap.yml配置為

    spring:

     cloud:

       config:

         uri: http://localhost:8080/

         profile: dev

         label: master

     application:

       name: foobar

3.     寫一個(gè)Controller

Spring Cloud Config 入門

4.     啟動(dòng)config Client。

訪問http://localhost:8081/configServer

可以從config Server中獲取到配置文件中的值。

Spring Cloud Config 入門

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

名稱欄目:SpringCloudConfig入門-創(chuàng)新互聯(lián)
URL鏈接:http://www.rwnh.cn/article20/dpeijo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作定制開發(fā)、做網(wǎng)站網(wǎng)站維護(hù)、響應(yīng)式網(wǎng)站、網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
新干县| 益阳市| 岳阳县| 昌都县| 拉孜县| 安西县| 盐亭县| 紫云| 原平市| 南乐县| 图木舒克市| 新绛县| 涡阳县| 庆元县| 云龙县| 大丰市| 龙门县| 库尔勒市| 银川市| 曲靖市| 登封市| 通许县| 聂荣县| 巴林左旗| 平舆县| 湘乡市| 贡嘎县| 会理县| 桐柏县| 攀枝花市| 驻马店市| 钟祥市| 抚顺县| 拉孜县| 新和县| 呼和浩特市| 隆昌县| 阜城县| 蓬莱市| 怀柔区| 彰武县|