1、yml配置:
#Apollo 配置
app:
id: sep #应用ID (与apollo中的appid对应)
apollo:
ca: /opt/data/ #配置本地配置缓存目录
cluster: default #指定使用哪个集群的配置
meta: http://xxxx:8083 #DEV环境配置中心地址 (configservice服务地址)
autoUpdateInjectedSpringProperties: true #是否开启 Spring 参数自动更新
bootstrap:
enabled: true #是否开启 Apollo
namespaces: application #设置 Namespace (可apollo 自己定义)
eagerLoad:
enabled: false #将 Apollo 加载提到初始化日志系统之前
2、引入依赖:
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.4.0</version>
</dependency>
3、在启动类上加注解
4、启动
4.1 如是idea需要在环境中的vm options 加上:
-Dapollo.configService=http://xxxxx:8083 -Denv=dev
4.2 如果是打包命令运行:
nohup java -Dapollo.configService=http://xxxxxx:8083 -Denv=dev -jar 包名 &