SpringSide团队日志

spring配置文件的更新

作者 calvin 目标文章 项目日志 - 2006-07-30

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

  1. <bean id="testPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
  2. <property name="location" value="classpath:context/test/test.properties"/>
  3. <property name="ignoreInvalidKeys" value="true"/>
  4. </bean>

test.properties文件如下

  1. dataSource.url=jdbc:hsqldb:res:default-db

如此配置之下,applicationContext中dataSource bean的url 就会被透明的修改成嵌入式数据的模式。



发表评论








 authimage