参考实例:
-
配置中心:
在配置中心文件中添加内容
1
iop.xbt.service.config.hello=hello world
-
服务中使用:
1、在 application.properties中的使用如下
1
config.hello=${iop.xbt.service.config.hello}
2、使用@Value的方式使用
1
2
3
4
5
6
7
8
@Value("${iop.xbt.service.config.hello}")
private String configVal;
@Test
public void testGetConfig(){
System.out.println("从配置中心获取到的config.hello的值:"+configVal);
}
近期评论