SpringBoot读取配置⽂件(从classpathfile读取ymlproperties⽂
件)
⼀、读取properties⽂件
使⽤配置项@PropertySource
⼆、读取yml⽂件
spring怎么读英文怎么读
启动类添加下⾯代码:
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new FileSystemResource("/l"));//File引⼊
/
/yaml.setResources(new ClassPathResource("l"));//class引⼊
configurer.Object());
return configurer;
}
1、引⼊多个配置⽂件:yaml.setResources(new ClassPathResource("l"), new ClassPathResource("l")); 

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。