1,下载Nacos,并放到服务器
2,进度到Nacos所在目录并解压
3,进入到nacos目录并启动
http://192.168.xxx.xxx:8848/nacos/index.html
默认登陆账号和明码
账号:nacos
明码:nacos
4,进入我的项目配置信息
(此处为spring-boot我的项目,文档和代码示例能够再次看:
https://nacos.io/zh-cn/docs/q…)
5,测试能够失常应用:
@RestController
@NacosPropertySource(dataId = "test",autoRefreshed = true)
public class test1 {
@NacosValue(value = "${url:kason}", autoRefreshed = true)
private String url = "";
@NacosValue(value = "${user:kason}", autoRefreshed = true)
private String user = "";
@NacosValue(value = "${pass:pass}", autoRefreshed = true)
private String pass = "";
@GetMapping(value="/testNacos")
public Map<String,String> testNacos() {
Map<String, String> map = new HashMap<>();
map.put("url", url);
map.put("user", user);
map.put("pass", pass);
return map;
}
@GetMapping(value="/test01")
public String test01() {
return "how are you?";
}
}
发表回复