spring-datasource.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- 装配数据源 --> <bean class="org.apache.tomcat.dbcp.dbcp.BasicDataSource" name="dataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/crm"></property> <property name="username" value="root"></property> <property name="password" value="root"></property> </bean> <!-- 装配SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> </props> </property> <property name="mappingResources"> <list> <value>org/niit/springtrans/entities/Account.hbm.xml</value> <value>org/niit/springtrans/entities/Card.hbm.xml</value> <value>org/niit/springtrans/entities/Tradecredential.hbm.xml</value> </list> </property> </bean> </beans> spring-dao.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean name="baseDao" class="org.niit.springtrans.dao.BaseDao"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean name="accountDao" class="org.niit.springtrans.dao.AccountDao" parent="baseDao" /> <bean name="cardDao" class="org.niit.springtrans.dao.CardDao" parent="baseDao" /> <bean name="tcDao" class="org.niit.springtrans.dao.TradecredentialDao" parent="baseDao" /> </beans> spring-biz.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean name="accountBizTarget" class="org.niit.springtrans.biz.impl.AccountBiz"> <property name="accountDao" ref="accountDao"></property> </bean> <bean name="cardBizTarget" class="org.niit.springtrans.biz.impl.CardBiz"> <property name="cardDao" ref="cardDao"></property> </bean> <bean name="tradeBizTarget" class="org.niit.springtrans.biz.impl.TradeBiz"> <property name="tcDao" ref="tcDao"></property> <property name="cardDao" ref="cardDao"></property> </bean> </beans> spring-transaction.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- 事务属性源 --> <bean name="transactionAttributeSource" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource"> <property name="properties"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="trade">PROPAGATION_REQUIRES_NEW</prop> </props> </property> </bean> <!-- 事务管理器 --> <bean name="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean name="TemplateBiz" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionAttributeSource" ref="transactionAttributeSource"></property> <property name="transactionManager" ref="transactionManager"></property> </bean> <!-- 代理后的业务对象[支持事务] --> <bean name="accountBiz" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" parent="TemplateBiz"> <property name="proxyInterfaces"> <list> <value>org.niit.springtrans.biz.IAccountBiz</value> </list> </property> <property name="target" ref="accountBizTarget"></property> </bean> <!-- 代理后的业务对象[支持事务] --> <bean name="cardBiz" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" parent="TemplateBiz"> <property name="proxyInterfaces"> <list> <value>org.niit.springtrans.biz.ICardBiz</value> </list> </property> <property name="target" ref="cardBizTarget"></property> </bean> <!-- 代理后的业务对象[支持事务] --> <bean name="tradeBiz" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" parent="TemplateBiz"> <property name="proxyInterfaces"> <list> <value>org.niit.springtrans.biz.ITradeBiz</value> </list> </property> <property name="target" ref="tradeBizTarget"></property> </bean> </beans>