<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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<import resource="spring-dao.xml"/>
<context:component-scan base-package="com.imooc.oa.biz"/>/* */
<aop:aspectj-autoproxy/>/*声明式事务自动代理 */
<bean id="transationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">/*事务管理器 */
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="transationManager">/* 声明通知并指定事务管理器*/
<tx:attributes>/*扫描的时候切入点的方法进行过滤 */
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>/*必须开启一个事务 */
</tx:attributes>
</tx:advice>
<aop:config>/*通知和切入点进行关联 */
<aop:pointcut id="txpc" expression="execution(* com.imooc.oa.biz.*.*(..))"/>/*任意返回值 biz包下所有类的所有名字的方法任意参数进行过滤 */
<aop:advisor advice-ref="txAdvice" pointcut-ref="txpc"/>
</aop:config>
</beans>
Spring-service.xml相关配置
最新推荐文章于 2021-08-11 22:04:45 发布