Springboot集成Apollo

一、有Apollo配置中心提供配置

windows本地部署apollo: https://blog.csdn.net/qq_35556233/article/details/104626366

二、Springboot項目接入apollo

1、在apollo中添加項目配置

其中appid在springboot接入apollo中需要配置

新建之後就和提供的例子一樣

可以在其中添加發布你想要增加的配置信息

2、springboot接入必需配置如下配置:

app_id 你所創建的apollo配置項目的id

meta:你的apollo項目請求地址

Environment:dev、fat、uat、pro四種環境

放在application.yml文件中的配置

apollo:
  bootstrap:
    enabled: true

app:
  id: short_url

其中apollo.meta和Environment可以加在application.yml文件中也可以放在server.properties文件中

windows:C:\opt\settings\server.properties

linux: /opt/settings/server.properties

server.properties內容如下:

env=DEV
apollo.meta=http://127.0.0.1:8080/

3、maven中添加依賴

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

4、注入配置信息

@EnableApolloConfig
@Value("${redisDatabase}")

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章