- Spring boot 通过流来获取xml 中的参数
String file="application-"+profile+".yml";
ClassPathResource resource = new ClassPathResource(file);
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
String name = properties.getProperty("spring.cloud.nacos.config.server-addr");
String name1 = properties.getProperty("spring.cloud.nacos.discovery.server-addr");
- Spring boot 通过流来获取yml 中的参数
String file="application-"+profile+".yml";
YamlPropertySourceLoader yamlPropertySourceLoader=new YamlPropertySourceLoader();
List<PropertySource<?>> load = yamlPropertySourceLoader.load(file, resource);
PropertySource<?> propertySource = load.get(0);
Object property = propertySource.getProperty("spring.cloud.nacos.config.server-addr");
Object property1 = propertySource.getProperty("spring.cloud.nacos.discovery.server-addr");