一、有Apollo配置中心提供配置
windows本地部署apollo: https://blog.youkuaiyun.com/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}")