<!-- 配置事务管理器,使用Hibernate局部事务管理器策略 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    
    <!-- 配置事务拦截器 -->
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <!-- 事务拦截器bean需要依赖注入一个事务管理器 -->
        <property name="transactionManager" ref="transactionManager"/>
     <property name="transactionAttributes">
    <!-- 下面定义事务传播属性 -->
    <props>
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
     <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
</bean>

<!-- 定义BeanNameAutoProxyCreator -->
    <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    <!-- 指定对满足哪些bean name的bean自动生成业务代理 -->
    <property name="beanNames">
            <!-- 下面是所有需要自动创建事务代理的bean,此处可增加其他需要自动创建事务代理的bean -->
            <list>
                <value>userService</value>
            </list>
    </property>
        <!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器 -->
        <property name="interceptorNames">
            <list>
                <!-- 此处可增加其他新的Interceptor -->
                <value>transactionInterceptor</value> 
            </list>
        </property>
    </bean>还要加个jta包