参考 :http://blog.youkuaiyun.com/yyhjava/article/details/53283515
PropertySourcesPlaceholderConfigurer和PropertyPlaceholderConfigurer冲突
SpringBoot 会注册一个 PropertySourcesPlaceholderConfigurer,
SpringBoot之前版本都是使用PropertyPlaceholderConfigurer,
所以对老项目升级的时候会出现有些配置读取不到,有些可以读取,很是诧异。
解决方案:如果系统使用springBoot,则继承PropertySourcesPlaceholderConfigurer,调用setProperties()方法把老的Properties设置进去,
然后系统只用一份PropertySourcesPlaceholderConfigurer.具体代码如下
@Configuration public class ColumbusConfig extends PropertySourcesPlaceholderConfigurer implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { setProperties(loadOldConfig()); } public static Properties loadOldConfig() { return ......; } }