1.手动创建一个配置:
配置成功后的列表页面:
2.通过代码获取配置信息
<dependencies> <dependency> <groupId>com.alibaba.nacos</groupId> <artifactId>nacos-client</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> </dependency> </dependencies>
public class NacosClient { public static void main(String[] args) throws NacosException { String serverAddr = "127.0.0.1:8848"; String dataId = "nacos-demo.yaml"; String group = "DEFAULT_GROUP"; Properties properties = new Properties(); properties.put("serverAddr",serverAddr); ConfigService configService = NacosFactory.createConfigService(properties); String config = configService.getConfig(dataId, group, 5000); System.out.println(config); } } #输出结果 pagehelper: helperDialect: mysql reasonable: true