spring+hibernate配置模式(非注解)
applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" >
<!--数据源-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<property name="url" value="jdbc:mysql://localhost:3306/club?
useUnicode=true&characterEncoding=UTF-8"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<!-- <property name="initialSize" value="${connection.initialSize}"></property> -->
<property name="maxActive" value="50"></property>
<property name="maxIdle" value="80"></property>
<property name="minIdle" value="20"></property>
<property name="maxWait" value="3000"></property>
</bean>
<!--二级缓存-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations">
<list>
<value>classpath:/com/uplooking/club/looker/entity/looker.hbm.xml</value>
<value>classpath:/com/uplooking/club/vip/entity/vip.hbm.xml</value>
<value>classpath:/com/uplooking/club/clubservice/entity/serviceclub.hbm.xml</value>
<value>classpath:/com/uplooking/club/cluborder/entity/orderclub.hbm.xml</value>
<value>classpath:/com/uplooking/club/product/entity/*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
<!--也可以直接挂载hibernate.cfg.xml配置文件
<property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
–>
</bean>
<!-- 一级缓存-->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>