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)境名稱,開(kāi)發(fā)、測(cè)試、生產(chǎn)
Lable:倉(cāng)庫(kù)分支、默認(rèn) master分支
另附:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
簡(jiǎn)單了解JAVA內(nèi)存泄漏和溢出區(qū)別及聯(lián)系
這篇文章主要介紹了簡(jiǎn)單了解JAVA內(nèi)存泄漏和溢出區(qū)別及聯(lián)系,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-03-03
java實(shí)現(xiàn)貪吃蛇游戲代碼(附完整源碼)
這篇文章主要介紹了java實(shí)現(xiàn)貪吃蛇游戲代碼(附完整源碼),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-01
Spring Cloud Ubuntu環(huán)境部署的步驟與注意事項(xiàng)
這篇文章主要給大家介紹了關(guān)于Spring Cloud Ubuntu環(huán)境部署的步驟與注意事項(xiàng),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Spring Cloud具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
Java編程打印購(gòu)物小票實(shí)現(xiàn)代碼
這篇文章主要介紹了Java編程打印購(gòu)物小票實(shí)現(xiàn)代碼,具有一定參考價(jià)值,需要的朋友可以了解下。2017-11-11
SpringMVC如何在生產(chǎn)環(huán)境禁用Swagger的方法
本篇文章主要介紹了SpringMVC如何在生產(chǎn)環(huán)境禁用Swagger的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-02-02

