Loading

applicationContext.xml文件如何调用外部properties等配置文件

只需要在applicationContext.xml文件中添加一行:
<!-- 导入外部的properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>  
其中:location属性是指该文件的位置。
如果是在src目录下的话,该位置为:classpath:文件名.后缀
如果是在/WEB-INF/目录下的话,该位置为: /WEB-INF/文件名.后缀

但是要注意,不要放错位置了,<context:property-placeholder>不能发到<bean></bean>标签里面去。
或者会报错;





posted @ 2015-05-22 21:35  JamKong  阅读(2085)  评论(0编辑  收藏  举报