SpringCloud配置中心Config過(guò)程解析
1.什么是配置中心
統(tǒng)一管理配置,怏速切換各個(gè)環(huán)境的配置
相關(guān)產(chǎn)品:
百度的 discont
https://github.com/knightliao/disconf
阿里的diamand
https://github.com/takeseem/diamond
springcloud的configs-server:
http://cloud.spring.io/spring-cloud-config/
2.添加依賴
<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>
3.啟動(dòng)類添加注解@EnableConfigServer
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer; @SpringBootApplication @EnableConfigServer public class ConfigServiceApplication { public static void main(String[] args) { SpringApplication.run(ConfigServiceApplication.class, args); } }
4.修改application.yml配置
server: port: 9100 eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ spring: application: name: config-server cloud: config: server: git: #倉(cāng)庫(kù)地址,去掉git uri: https://gitee.com/YTHeng/config_cloud #git服務(wù)器登錄的用戶名和密碼,我這邊使用的是碼云 username: 12345678@qq.com password: 12345678. #超時(shí)時(shí)間 timeout: 5 #分支 default-label: master
5.在碼云服務(wù)器新建倉(cāng)庫(kù)和文件
6.訪問(wèn)地址
http://localhost:9100/master/product-service-dev.yml
路徑訪問(wèn)方式
/{name}-{profiles}. properties
/{name}-{profiles}.yml
/{name}-{profiles}.json
/{label}/{name]-{profiles].yml
name:服務(wù)器名稱
profile:環(huán)境名稱,開發(fā)、測(cè)試、生產(chǎn)
Lable:倉(cāng)庫(kù)分支、默認(rèn) master分支
另附:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Java中的stream流的概念解析及實(shí)際運(yùn)用總結(jié)
流是指?jìng)鬏敃r(shí)的數(shù)據(jù),Java為流準(zhǔn)備了很多內(nèi)置類,尤其是IO輸入輸出流非常常用,這里我們來(lái)看一下Java中的stream流的概念解析及實(shí)際運(yùn)用總結(jié)2016-06-06Java實(shí)現(xiàn)對(duì)象復(fù)制的方法實(shí)例
這篇文章主要介紹了Java實(shí)現(xiàn)對(duì)象復(fù)制的方法實(shí)例,深復(fù)制:復(fù)制出來(lái)的對(duì)象中的變量(包括基本類型和字符串)和原來(lái)的對(duì)象的值都相同,引用對(duì)象也會(huì)指向復(fù)制出來(lái)的對(duì)象,需要的朋友可以參考下2023-08-08Java編寫網(wǎng)上超市購(gòu)物結(jié)算功能程序
這篇文章主要為大家詳細(xì)介紹了Java編寫網(wǎng)上超市購(gòu)物結(jié)算功能程序的具體代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-06-06SpringBoot集成百度AI實(shí)現(xiàn)人臉識(shí)別的項(xiàng)目實(shí)踐
本文主要介紹了SpringBoot集成百度AI實(shí)現(xiàn)人臉識(shí)別的項(xiàng)目實(shí)踐,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05淺談Spring事務(wù)傳播行為實(shí)戰(zhàn)
這篇文章主要介紹了淺談Spring事務(wù)傳播行為實(shí)戰(zhàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09啟用springboot security后登錄web頁(yè)面需要用戶名和密碼的解決方法
這篇文章主要介紹了啟用springboot security后登錄web頁(yè)面需要用戶名和密碼的解決方法,也就是使用默認(rèn)用戶和密碼登錄的操作方法,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02Java策略模式實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車功能
這篇文章主要介紹了Java策略模式實(shí)現(xiàn)簡(jiǎn)單地購(gòu)物車,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08