午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

使用Springboot整合Apollo配置中心

瀏覽:13日期:2023-02-21 08:48:07
Apollo簡介

Apollo(阿波羅)是攜程框架部門研發的分布式配置中心,能夠集中化管理應用不同環境、不同集群的配置,配置修改后能夠實時推送到應用端,并且具備規范的權限、流程治理等特性,適用于微服務配置管理場景。

官方網站 https://github.com/ctripcorp/apollo

Apollo 環境搭建

詳細步驟參見: https://github.com/ctripcorp/apollo/wiki/Quick-Start

使用Springboot整合Apollo配置中心

使用Springboot整合Apollo配置中心

官網已經很詳細的說明了操作步驟。但是有很多前置條件才能完成安裝。

1、必須要有git環境,才能下載Apollo代碼

yum –y install git

然后需要clone代碼。

2、安裝docker-compose環境

地址:https://github.com/docker/compose/releases

curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose

使用Springboot整合Apollo配置中心

測試結果

使用Springboot整合Apollo配置中心

至此為止,就可以運行文檔中的腳本了。

安裝完成之后,需要等待兩三分鐘就可以訪問了。

使用Springboot整合Apollo配置中心

輸入賬號:apollo,密碼:admin

使用Springboot整合Apollo配置中心

點擊創建項目

使用Springboot整合Apollo配置中心

點擊新建配置

使用Springboot整合Apollo配置中心 使用Springboot整合Apollo配置中心

點擊發布

發布之后的配置才能生效

使用Springboot整合Apollo配置中心 使用Springboot整合Apollo配置中心

查看發布歷史

使用Springboot整合Apollo配置中心

整合SpringBoot項目

1、使用idea新建springboot項目

2、修改pom.xml

<dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client</artifactId> <version>1.1.0</version></dependency><dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-core</artifactId> <version>1.1.0</version></dependency>

3、創建apollo配置文件

local.meta=http://192.168.75.50:8080dev.meta=http://192.168.75.50:8080fat.meta=${fat_meta}uat.meta=${uat_meta}lpt.meta=${lpt_meta}pro.meta=${pro_meta}

使用Springboot整合Apollo配置中心

4、創建app.id配置文件,每一個應用基本使用一個app.id

app.id=cyp_001

使用Springboot整合Apollo配置中心

5、讀取apollo中的配置信息,防止配置沒有注入,一定要設置默認值!

package com.chen.apolloconfig;import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Configuration;@Configuration@EnableApolloConfig@SpringBootApplicationpublic class ApolloConfigApplication { public static void main(String[] args) {SpringApplication.run(ApolloConfigApplication.class, args); }}

```package com.chen.apolloconfig.controller;import org.springframework.beans.factory.annotation.Value;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class IndexController { @Value('${name:chenyongpeng}') private String name; @GetMapping('/getName') public String getMyName(){return name; }}```![在這里插入圖片描述](https://img-blog.csdnimg.cn/20190606172204975.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2NoZW4xODY3NzMzODUzMA==,size_16,color_FFFFFF,t_70)總結

至此,springboot整合apollo配置中心已經驗證通過!

springcloud的配置中心是基于git或者gitte,gitlib等托管中心!

apollo是基于數據庫和本地緩存!

采坑之處

項目啟動之后一直說是找不到dev環境!!!

此處需要在本機下新建環境配置!

使用Springboot整合Apollo配置中心

env=DEV

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 国产精品一区二区不卡 | 色av吧| 国产一区二区三区精品视频 | 免费在线中文字幕 | 狠狠干五月天 | av片在线免费看 | 欧美日韩精品免费 | 日韩成人精品一区 | 国产特级毛片 | 五月婷婷视频在线观看 | 午夜精品视频 | 激情高潮呻吟抽搐喷水 | 欧美日韩a| china激情老汉69老头 | 美国一级大黄一片免费中文 | 日韩一区二 | 成年人在线观看网站 | 欧美综合在线观看 | 成人影视在线播放 | 韩国视频一区二区 | 白嫩白嫩国产精品 | 国产中文字幕一区二区三区 | 国产精品中文字幕在线观看 | 免费看av大片 | 色999视频| 69福利区| av黄色网址 | 天天操夜夜欢 | 观看av免费 | 国产剧情自拍 | 黄色a级片在线观看 | 国产成人免费 | 性做爰过程免费看 | 成年人免费毛片 | 婷婷激情影院 | 欧美日本一本 | 成人亚洲片 | 国产黄色免费网站 | 亚洲专区欧美 | 日韩精品视频在线看 | 日韩色影院 |