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;
    }

}

猜你喜欢

转载自www.cnblogs.com/ligh-test/p/10752072.html