码迷,mamicode.com
首页 > 其他好文 > 详细

解决关于配置文件的占位符无法读取问题

时间:2017-09-20 11:57:06      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:无法   .property   配置   org   source   text   问题   命名空间   red   

前提是:

  其他的配置文件中已经配置了<context:property-placeholder location="classpath:jdbc.properties"/>

主要原因是:

  Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代PropertyPlaceholderConfigurer了)。而<context:property-placeholder/>这个基于命名空间的配置,其实内部就是创建一个PropertyPlaceholderConfigurer Bean而已。换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:property-placeholder/>),其余的会被Spring忽略掉。

解决方法是:
  改成<context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>

解决关于配置文件的占位符无法读取问题

标签:无法   .property   配置   org   source   text   问题   命名空间   red   

原文地址:http://www.cnblogs.com/BINGJJFLY/p/7560222.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!