- <?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: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-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
- <bean id="testAction" class="test.action.Stuts2ActionTest">
- <property name="service" ref="templatesService"></property>
- </bean>
- <bean id="templatesService"
- class="test.service.impl.TaoTemplatesServiceImpl">
- <property name="dao" ref="templatesDAO" />
- </bean>
- <bean id="templatesDAO" class="test.dao.impl.TaoTemplatesDAOImpl">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <!--定义数据源-->
- <bean id="dataSource"
- class="org.apache.commons.dbcp.BasicDataSource">
- <!-- 定义数据库驱动-->
- <property name="driverClassName">
- <value>oracle.jdbc.driver.OracleDriver</value>
- </property>
- <!-- 定义数据库url-->
- <property name="url">
- <value>jdbc:oracle:thin:@192.168.1.96:1521:yxdb</value>
- </property>
- <!-- 定义数据库用户名-->
- <property name="username">
- <value>yxuser</value>
- </property>
- <!-- 定义数据库密码-->
- <property name="password">
- <value>yxuser</value>
- </property>
- </bean>
- <!--定义一个hibernate的SessionFactory-->
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <!-- 定义SessionFactory必须注入DataSource-->
- <property name="dataSource">
- <ref local="dataSource" />
- </property>
- <property name="mappingResources">
- <list>
- <!--以下用来列出所有的PO映射文件-->
- <value>test/mapping/Tao_Templates.hbm.xml</value>
- </list>
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">
- org.hibernate.dialect.Oracle10gDialect
- </prop>
- <prop key="hibernate.show_sql">true</prop>
- <!--此处用来定义hibernate的SessionFactory的属性:
- 不同数据库连接,启动时选择create,update,create-drop -->
- <prop key="hibernate.hbm2ddl.auto">update</prop>
- </props>
- </property>
- </bean>
- <bean id="transactionManager"
- class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
- </property>
- </bean>
- 1 <!--
2 <bean id="transactionManager"
3 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
4 <property name="dataSource" ref="jamon-proxy-DataSource"></property>
5 </bean>
6 -->
7 <!-- 事务通知 -->
8 <tx:advice id="txAdvice" transaction-manager="transactionManager">
9 <tx:attributes>
10 <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception,SmoException,BmoException,DaoException" />
11 <tx:method name="del*" propagation="REQUIRED" rollback-for="Exception,SmoException,BmoException,DaoException" />
12 <tx:method name="upd*" propagation="REQUIRED" rollback-for="Exception,SmoException,BmoException,DaoException" />
13 <tx:method name="*" propagation="SUPPORTS" read-only="true" />
14 </tx:attributes>
15 </tx:advice>
16 <!-- Spring AOP config
17 解释一下(* com.evan.crm.service.*.*(..))中几个通配符的含义:
18 第一个 * —— 通配 任意返回值类型
19 第二个 * —— 通配 包com.evan.crm.service下的任意class
20 第三个 * —— 通配 包com.evan.crm.service下的任意class的任意方法
21 第四个 .. —— 通配 方法可以有0个或多个参数
22 -->
23 <aop:config>
24 <aop:pointcut id="servicesPointcut" expression="execution(* com.jstrd.mss..*SMOImpl.*(..))" />
25 <aop:advisor advice-ref="bluePrint.txAdvice" pointcut-ref="servicesPointcut" />
26 </aop:config>
27
28 </beans>
29
30