hibernate.properties配置文件的简单配置信息:
dataSource.driverClassName= com.mysql.jdbc.Driver
dataSource.username = root
dataSource.password = root
dataSource.dialect = www.tongmap.cn.utils.MySQLDialectImpl
dataSource.url = jdbc:mysql://localhost:3306/sm
dataSource.hbm2ddl.auto = update
maven配置的jar依赖pom.xml,说明一下,native类型的jar包是我自己下载jar包后手工添加到本地仓库中的,并不是使用maven自动下载的(网络问题),使用maven下载需要把native修改为com.cloudhopper.proxool:
c3p0
c3p0
0.9.1.1
注意:我使用的c3p0版本为0.9.1.1,所以只要一个jar包就可以了,如果使用更新版本的c3p0,会有两个jar包,以c3p0-0.9.2.1为例,会需要以下依赖:
com.mchange
c3p0
0.9.2.1
com.mchange
mchange-commons-java
0.2.3.4
applicationContext.xml文件的配置,至于更详细的大家可以在官网中查看资料,每个配置的官网我在注释中有说明:
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
destroy-method="close">
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
${dataSource.dialect}
${dataSource.hbm2ddl.auto}
true
true
true
www.tongmap.cn.entity
class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
class="org.springframework.orm.hibernate4.HibernateTransactionManager">