SpringBoot配置读取不到 PropertySourcesPlaceholderConfigurer和PropertyPlaceholderConfigurer
2018-01-11 21:04
531 查看
参考 :http://blog.csdn.net/yyhjava/article/details/53283515
PropertySourcesPlaceholderConfigurer和PropertyPlaceholderConfigurer冲突
SpringBoot 会注册一个 PropertySourcesPlaceholderConfigurer,
SpringBoot之前版本都是使用PropertyPlaceholderConfigurer,
所以对老项目升级的时候会出现有些配置读取不到,有些可以读取,很是诧异。
解决方案:如果系统使用springBoot,则继承PropertySourcesPlaceholderConfigurer,调用setProperties()方法把老的Properties设置进去,
然后系统只用一份PropertySourcesPlaceholderConfigurer.具体代码如下
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 ......; } }
相关文章推荐
- spring通过.PropertyPlaceholderConfigurer读取配置文件
- Spring中配置和读取多个Properties文件-- PropertyPlaceholderConfigurer
- spring读取数据库的配置信息(url、username、password)时的<bean>PropertyPlaceholderConfigurer的用法
- PropertyPlaceholderConfigurer的用法(使用spring提供的类读取数据库配置信息.properties)
- 动态设置spring配置PropertyPlaceholderConfigurer location的路径
- PropertyPlaceholderConfigurer读取配置文件
- spring读取不到<context:property-placeholder的问题
- Spring PropertySourcesPlaceholderConfigurer工作原理
- Spring PropertyPlaceholderConfigurer Usage - 使用系统变量替换spring配置文件中的变量
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
- <value>${jdbc.driverClassName}</value>解读——PropertyPlaceholderConfigurer读取配置文件
- spring使用多个PropertyPlaceholderConfigurer的配置
- Spring代码实例系列-09:通过Spring PropertyPlaceholderConfigurer将properties配置的属性注入到xml配置文件中
- spring 配置文件 获取变量(PropertyPlaceholderConfigurer)
- Spring PropertyPlaceholderConfigurer初始化properties配置文件
- spring ApplicationContext.xml之PropertyPlaceholderConfigurer配置数据库
- spring使用多个PropertyPlaceholderConfigurer的配置
- Spring配置:用context:property-placeholder替换PropertyPlaceholderConfigurer
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置