现在的位置: 首页 > 综合 > 正文

spring加载资源文件

2013年12月03日 ⁄ 综合 ⁄ 共 473字 ⁄ 字号 评论关闭

项目达成jar后,spring配置文件只能加载jar包内的文件,为了解决这一问题,做了以下修改:

<bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 <property name="location">
  <value>jdbc.properties</value>
 </property>
</bean>

更改为:

<bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 <property name="location">
  <value>file:./jdbc.properties</value>
 </property>
</bean>

这样启动jar时,就可以加载与jar文件相同目录的资源文件jdbc.properties了。

抱歉!评论已关闭.