springboot配置多个yml文件

自定义properties bean,如下:

@Configuration
public class ConfigProperties {

    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ClassPathResource("config/busiConfig.yml"),new ClassPathResource("config/Rocketmq.yml"));
        configurer.setProperties(yaml.getObject());
        return configurer;
    }

}

 

posted @ 2019-04-22 18:51  知了肥  阅读(1712)  评论(0编辑  收藏  举报