spring配置文件的更新
1. spring的配置文件可以大量配置<beans default-lazy-init="true">来加快单元测试的速度。
不过注意那些PostFactoryBean 如PropertyPlaceholderConfigurer是不能lazy-init的,否则一不小心吃个大闷亏,还有那些springmvc-servlet.xml 似乎也不能lazy init.
2. 使用PropertyOverrideConfigurer来特别配置单元测试时的JDBC URL
PropertyOverrideConfigurer的详细情况见参考手册的3.7.2.2
<bean id="testPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"> <property name="location" value="classpath:context/test/test.properties"/> <property name="ignoreInvalidKeys" value="true"/> </bean>
test.properties文件如下
dataSource.url=jdbc:hsqldb:res:default-db
如此配置之下,applicationContext中dataSource bean的url 就会被透明的修改成嵌入式数据的模式。
静态链接网址 /
(0) 最新回复 /
(0) 引用
发表评论