日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

springboot集成Apollo分布式配置

發布時間:2024/4/17 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springboot集成Apollo分布式配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝Apollo服務

1.安裝mysql

地址:https://www.cnblogs.com/xuaa/p/10782352.html

2.下載Apollo源碼到本地

地址:https://github.com/ctripcorp/apollo

3.創建數據庫

創建configdb數據庫,數據庫腳本:apollo\scripts\db\migration\configdb\V1.0.0__initialization.sql

創建portaldb數據庫,數據庫腳本:apollo\scripts\db\migration\portaldb\V1.0.0__initialization.sql

4.修改打包腳本

腳本:apollo\scripts\build.bat

修改內容:

# 填寫ApolloConfigDB數據庫連接信息
set apollo_config_db_url="jdbc:mysql://172.29.22.151:3306/ApolloConfigDB?characterEncoding=utf8"
set apollo_config_db_username="root"
set apollo_config_db_password="123456"

rem apollo portal db info
# 填寫ApolloPortalDB連接信息
set apollo_portal_db_url="jdbc:mysql://172.29.22.151:3306/ApolloPortalDB?characterEncoding=utf8"
set apollo_portal_db_username="root"
set apollo_portal_db_password="123456"

rem meta server url, different environments should have different meta server addresses
# 填寫meta服務準備安裝的服務地址,我只安裝了dev
set dev_meta="http://172.29.22.151:8080"
set fat_meta="http://172.29.22.151:8080"
set uat_meta="http://172.29.22.151:8080"
set pro_meta="http://172.29.22.151:8080"

?5.打包

在apollo\scripts目錄下cmd命令行界面執行build.bat腳本進行打包,打包完成后將以下文件上傳到Linux服務器

apollo\apollo-adminservice\target\apollo-adminservice-1.4.0-SNAPSHOT-github.zip

apollo\apollo-configservice\target\apollo-configservice-1.4.0-SNAPSHOT-github.zip

apollo\apollo-portal\target\apollo-portal-1.4.0-SNAPSHOT-github.zip

6.啟動

將第5步上傳的三個zip文件解壓,分別執行三個目錄下的啟動腳本scripts/startup.sh

?7.創建項目

訪問可視化界面,地址:http://172.29.22.151:8070,默認賬號/密碼:apollo/admin

創建項目

項目創建成功后點擊項目,添加配置信息

然后點擊發布

springboot客戶端集成apollo分布式配置

1.添加依賴

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

2.修改application.properties

加入以下配置,注:app.id必須要和創建項目時填寫應用Id相同

app.id=elk-demo
apollo.meta=http://172.29.22.151:8080

3.獲取配置信息

在Springboot項目啟動類中加入注解

@EnableApolloConfig

通過注解獲取配置信息,注:111111為默認值

@Value("${test.name}")
private String name;
或者 @Value("${test.name:111111}")
private String name;

轉載于:https://www.cnblogs.com/xuaa/p/10813163.html

總結

以上是生活随笔為你收集整理的springboot集成Apollo分布式配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。