spring 分散配置
2024-08-28 15:57:42
Spring简化了加载资源文件的配置,可以通过<context:property-placeholder去加载,这个元素的写法如下:
<context:property-placeholder location="classpath:jdbc.properties"/>
如果想要配置多个properties文件
<context:property-placeholder location="classpath:jdbc1.properties"/> <context:property-placeholder location="classpath:jdbc2.properties"/>
这种方式是不被允许的,一定会出"Could not resolve placeholder"
解决方案:
(1) 在Spring 3.0中,可以写:
<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/> <context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>
(2) 但是在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,所以就不能使用上面的那种方法去配置,可以改如下的格式:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/jdbc.properties</value> </list> </property> </bean>
最新文章
- SDWebImage源码解读 之 NSData+ImageContentType
- css3中变形函数(同样是对元素来说的)和元素通过改变自身属性达到动画效果
- CSS实现垂直居中的5种方法
- Bootstrap页面布局10 - BS代码
- 升级或安装 GNOME Shell
- S2sh整合MAven项目所需坐标大全
- c/c++面试总结(1)
- BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
- jQuery ajax 传递数组到struts2
- 自定义控件出现“loaded nib but the view outlet was not set”
- blur事件
- Linux下部署
- selenium模拟浏览器对搜狗微信文章进行爬取
- 【转载】 mybatis入门系列四之动态SQL
- BUAAOO P1-P3 Expression Dirivation
- Unity网格合并_材质合并
- Java如何检查日期格式是否正确?
- leetcode第三题
- Codeforces 977F - Consecutive Subsequence - [map优化DP]
- python基础(9)-迭代器&;生成器函数&;生成器进阶&;推导式