spring junit--基础配置

2014-11-23 23:13:51 · 作者: · 浏览: 0

spring官方文档总提示要进行SpringJunit测试必须先配置两个信息:

1、使用Spring IOC功能配置

2、配置正确的JDBC或ORM框架连接数据库

下面进行spring3和hibernate4测试平台基础配置说明:


xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">





destroy-method="close">
mysql.jdbc.Driver" />














class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">




class="org.springframework.orm.hibernate4.HibernateTransactionManager">




1、注意如果你使用的是hibernate3则需要将org.springframework.orm.hibernate4.HibernateTransactionManage改为org.springframework.orm.hibernate3.HibernateTransactionManage

2、此处使用出c3p0连接池,可以根据实际情况更改

3、hibernate配置文件为:


"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">




org.hibernate.dialect.MySQLDialect


需要制定数据库方言