添加依赖jar
客户端jar
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.5.0</version>
</dependency>
开启配置中心
类加注解
@EnableApolloConfig
从配置中心读数据
1.注入数据
在类里面,注入数据
@ApolloConfig
Config config;
2.读配置数据
在方法里读数据
String merQrcodeNum = config.getProperty("merQrcodeNum", "5"); //1.从配置中心读数据 2.如果没有读到数据,就使用默认值5(即第二个参数)
配置
配置文件添加
### apollo配置中心
# 项目id
app.id=xxx-manager-service //在配置中心管理系统添加应用和应用id
# 注册中心ip/port
apollo.meta=${filter.apollo.meta} //
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。