64 lines
3.4 KiB
XML
64 lines
3.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd"
|
|
default-lazy-init="true">
|
|
|
|
<description>Spring测试环境配置文件 </description>
|
|
|
|
<!-- 定义易受环境影响的变量 -->
|
|
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
|
<property name="ignoreResourceNotFound" value="true" />
|
|
<property name="locations">
|
|
<list>
|
|
<!-- 标准配置 -->
|
|
<value>classpath*:/application.properties</value>
|
|
<!-- 本地开发环境配置 -->
|
|
<value>classpath*:/application.local.properties</value>
|
|
<!-- 测试环境配置 -->
|
|
<value>classpath*:/application.test.properties</value>
|
|
<!-- 本地测试环境配置 -->
|
|
<value>classpath*:/application.test-local.properties</value>
|
|
</list>
|
|
</property>
|
|
</bean>
|
|
|
|
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
|
|
<context:component-scan base-package="org.springside.examples.miniservice" />
|
|
|
|
<!-- 以静态变量保存ApplicationContext -->
|
|
<bean class="org.springside.modules.test.spring.SpringContextHolder" lazy-init="false" />
|
|
|
|
<!-- 数据源配置,在测试环境使用JDBC直接连接 -->
|
|
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
|
<property name="driverClassName" value="${jdbc.driver}" />
|
|
<property name="url" value="${jdbc.url}" />
|
|
<property name="username" value="${jdbc.username}" />
|
|
<property name="password" value="${jdbc.password}" />
|
|
</bean>
|
|
|
|
<!-- 运行脚本初始化内存数据库 -->
|
|
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
|
|
<jdbc:script location="classpath:sql/h2/schema.sql" />
|
|
</jdbc:initialize-database>
|
|
|
|
<!-- myBatis配置 -->
|
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
<property name="dataSource" ref="dataSource" />
|
|
<property name="configLocation" value="classpath:/mapper/Configuration.xml" />
|
|
<property name="mapperLocations" value="classpath:/mapper/*Mapper.xml" />
|
|
</bean>
|
|
|
|
<!-- 事务管理器配置, 使用jdbc事务 -->
|
|
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
<property name="dataSource" ref="dataSource" />
|
|
</bean>
|
|
|
|
<!-- 使用annotation定义事务 -->
|
|
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
|
|
|
|
<!-- JSR303 Validator定义 -->
|
|
<bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
|
|
</beans> |