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>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:./config/jdbc.properties</value>