applicationContext.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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" 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/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-autowire="byName" default-lazy-init="true">
<!-- 建立数据源 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="driverUrl" value="jdbc:oracle:thin:@10.1.100.10:1521:testerp"></property>
<property name="user" value="ecommerce"></property>
<property name="password" value="ecommerce"></property>
<property name="minimumConnectionCount" value="10"></property>
<property name="maximumConnectionCount" value="100"></property>
</bean>
<!-- sessionFactory配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- 实体映射文件夹 -->
<!-- <property name="mappingDirectoryLocations">
<list>
<value>classpath:com/testdl/demo/model/maps</value>
</list>
</property> -->
<!-- 实体映射文件-->
<property name="mappingResources">
<list>
<value>test/testEntity/Puser.hbm.xml</value>
<value>test/testEntity/PuserFavorite.hbm.xml</value>
</list>
</property>
<!-- 数据库属性配置 -->
<property name="hibernateProperties">
<props>
<!-- SQL方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<!-- 为true表示将Hibernate发送给数据库的sql显示出来 -->
<prop key="hibernate.show_sql">true</prop>
<!-- 格式化输出sql语句 -->
<prop key="hibernate.format_sql">true</prop>
<!-- 收集有助于性能调节的统计数据 -->
<prop key="hibernate.generate_statistics">true</prop>
<!-- 一次读的数据库记录数 -->
<prop key="hibernate.jdbc.fetch_size">50</prop>
<!-- 释放jdbc连接 -->
<prop key="hibernate.connection.release_mode">auto</prop>
<!-- 数据库超时自动连接 -->
<prop key="hibernate.autoReconnect">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<!-- 开启二级缓存 -->
<!-- <prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop> -->
</props>
</property>
</bean>
<!-- 事务管理器配置 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- aop事务处理 ********************* start *************************-->
<tx:annotation-driven/>
<!-- 启动@AspectJ支持 -->
<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/>
<!-- 启动@AspectJ支持 -->
<!-- <aop:aspectj-autoproxy/> -->
<!-- 自动搜索切面类 -->
<context:component-scan base-package="test.testAction"><!-- annotation-config="true" -->
<!-- <context:exclude-filter type="annotation" expression="org.aspectj.lang.annotation.Aspect"/> -->
</context:component-scan>
<!-- 定义切点和织入 -->
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* test.testDao..*DaoImpl.*(..))" advice-ref="txAdvice"/>
<aop:advisor pointcut="execution(* test..*ServiceImpl.*(..))" advice-ref="txAdvice"/>
</aop:config>
<!-- 定义切面 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="update*" read-only="false"/>
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- aop事务处理 ********************* end *************************-->
<!-- bean注入 ********************** start ****************************-->
<bean id="AdviceTest" class="test.testAction.AdviceTest"></bean>
<bean id="ftd" class="test.testDao.impl.FirstTestDaoImpl"></bean>
<bean id="fts" class="test.testServices.impl.FirstTestServiceImpl">
<property name="firstTestDao" ref="ftd"></property>
</bean>
<bean id="firstTestAction" class="test.testAction.FirstTestAction">
<property name="firstTestService" ref="fts">
</property>
</bean>
<!-- bean注入 *********************** end ***************************-->
</beans>