<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 数据源配置 -->
<bean id="userDao" class="login.dao.UserDao">
<property name="template">
<ref bean="hibernateTemp"/>
</property>
</bean>
<!-- sessionFactory的配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>login/vo/UserVo.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLdialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Spring用来管理Hibernate配置的事务代理 -->
<bean id="serviceLoginProxy" class="org.springframework.transaction.interceptor.TransactionProxyBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="userDao"/>
</property>
<property name="proxyTargetClass">
<ref bean="true"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save">PROPAGATION_REQUIRED</prop>
<prop key="find">PROPAGATION_REQUIRED, readOnly</prop>
</props>
</property>
</bean>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/hibernate?useUnicode=ture&characterEncoding=gbk</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>123</value>
</property>
</bean>
<!-- HibernateTemplate的配置 -->
<bean id="hibernateTemp" class="org.springframework.orm.hibernate3.HibernateTemplate">
<constructor-arg>
<ref bean="sessionFactory"/>
</constructor-arg>
</bean>
<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>