beans.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: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/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
         http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    
<!-- a service object; we will be profiling its methods -->
    
<context:annotation-config />
    
<context:component-scan base-package="com.bebig" />

    
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy
-method="close">
        
<property name="driverClassName" value="${jdbc.driverClassName}" />
        
<property name="url" value="${jdbc.url}" />
        
<property name="username" value="${jdbc.username}" />
        
<property name="password" value="${jdbc.password}" />
    
</bean>
    
<context:property-placeholder location="classpath:jdbc.properties" />

    
<bean id="sessionFactory"
        
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        
<property name="dataSource" ref="dataSource" />
<!--        <property name="annotatedClasses">-->
<!--            <list>-->
<!--                <value>com.bebig.model.User</value>-->
<!--                <value>com.bebig.model.Log</value>-->
<!--            </list>-->
<!--        </property>-->
        
<property name="packagesToScan">
            
<list>
                
<value>com.bebig.model</value>
            
</list>
        
</property>
        
<property name="hibernateProperties">
            
<props>
                
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                
<prop key="hibernate.show_sql">true</prop>
                
<prop key="hibernate.format_sql">true</prop>
                
<prop key="hibernate.hbm2ddl.auto">update</prop>
            
</props>
        
</property>
    
</bean>

    
<bean id="transactionManager"
        
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory" ref="sessionFactory" />
    
</bean>

<!-- 声明式事务XML配置方法 -->
    
<aop:config>
        
<aop:pointcut expression="execution(public * com.bebig.service..*.*(..))"
            id
="servicePointcut" />
        
<aop:advisor advice-ref="txAdvisor" pointcut-ref="servicePointcut" />
    
</aop:config>
    
<tx:advice id="txAdvisor" transaction-manager="transactionManager">
        
<tx:attributes>
            
<tx:method name="getUser" read-only="true" />
            
<tx:method name="add*" propagation="REQUIRED"/>
        
</tx:attributes>
    
</tx:advice>

</beans>