当前位置: 代码迷 >> Web前端 >> 施用file配置PropertyPlaceholderConfigurer的location属性
  详细解决方案

施用file配置PropertyPlaceholderConfigurer的location属性

热度:193   发布时间:2012-09-23 10:28:11.0
使用file配置PropertyPlaceholderConfigurer的location属性
Spring中,一般使用classpath:来配置PropertyPlaceholderConfigurer的location属性,今天想通过文件路径的方式进行配置,尝试了多次,发现似乎是只支持绝对路径方式,格式是:file:文件路径。配置如下:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 <property name="location" value="file:d:/xxx/websrc/WEB-INF/db.properties" />
</bean>


不知道谁还有没有更好的办法可以支持file:的相对路径。
1 楼 windelk 2012-03-22  
我刚刚试过了,可以配置相对路径
<bean id="propertyConfigurer" 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
       <property name="location"> 
           <value>file:./config/jdbc.properties</value> 
  相关解决方案