在自定义配置中加入:
package com.cps.trans.route.configuration;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
/**
* @author max woods
* @date 2018/8/27
*/
@Configuration
//@ImportResource(locations = {"classpath:config/channel.yml","classpath:config/cups.yml"})
public class CustomConfiguration {
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
// 从classpath导入
yaml.setResources(new ClassPathResource("/config/channel.yml"),
new ClassPathResource("/config/cups.yml"));
yaml.afterPropertiesSet();
configurer.setProperties(yaml.getObject());
return configurer;
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END











