<?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:context="http://www.springframework.org/schema/context"
     xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
            
            
            
             http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean  
           >  
         <property value="classpath:hibernate.cfg.xml" />  
         <property value="org.hibernate.cfg.AnnotationConfiguration" />
     </bean> 
<!-- 定义事务管理器(声明式的事务) -->  
     <bean
       >
         <property ref="sessionFactory" />
     </bean> 
    
     <bean  
       >  
         <property ref="transactionManager" />  
         <!-- 配置事务属性 -->  
         <property>  
             <props>  
                 <prop key="*">PROPAGATION_REQUIRED</prop>  
             </props>  
         </property>  
     </bean>
       
     <bean>  
         <property>  
             <list>  
                 <value>*Dao</value>
            </list>  
         </property>  
         <property>  
             <list>  
                 <value>transactionInterceptor</value>  
             </list>  
         </property>  
     </bean>  
   
     <!-- 配置DAO -->
     <bean>
         <property ref="sessionFactory" />
     </bean>
</beans>
第四种方式:使用tx标签配置的拦截器
<?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:context="http://www.springframework.org/schema/context"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
            
            
            
             http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
             http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:annotation-config />
     <context:component-scan base-package="com.linuxidc" />
<bean  
           >  
         <property value="classpath:hibernate.cfg.xml" />  
         <property value="org.hibernate.cfg.AnnotationConfiguration" />
     </bean> 

