spring?aop?pointcut?添加多個execution方式
spring aop pointcut 添加多個execution
spring aop添加多個包,用||或者or隔開
<!-- 只對業(yè)務(wù)邏輯層實施事務(wù) --> <aop:config expose-proxy="true"> <aop:pointcut expression="execution(* demo.ssh.daoImpl.*.*(..)) || execution(* demo.mes.daoImpl.*.*(..))" id="txPointcut" /> <!-- Advisor定義,切入點和通知分別為txPointcut、txAdvice --> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" /> </aop:config>
spring aop:pointcut--expression--多個execution連接
聲明式事務(wù),多個execution連接方法:
expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))"
spring的幫助手冊里有關(guān)于execution的連接方式的一句話:
Pointcut expressions can be combined using '&&', '||' and '!'.
但是我寫上&&就會報錯。很郁悶。。。
||和or的作用相同:在符合* pp.business.*.*(..)和* pp.business.impl.*.*(..)方法上都加上事務(wù)性。
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes > <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="insert*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config proxy-target-class="true"> <aop:pointcut id="allManagerMethod" expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/> </aop:config>
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java的@Transactional、@Aysnc、事務(wù)同步問題詳解
這篇文章主要介紹了Java的@Transactional、@Aysnc、事務(wù)同步問題詳解,現(xiàn)在我們需要在一個業(yè)務(wù)方法中插入一個用戶,這個業(yè)務(wù)方法我們需要加上事務(wù),然后插入用戶后,我們要異步的方式打印出數(shù)據(jù)庫中所有存在的用戶,需要的朋友可以參考下2023-11-11Mybatis調(diào)用Oracle存儲過程的方法圖文詳解
這篇文章主要介紹了Mybatis調(diào)用Oracle存儲過程的方法介紹,需要的朋友可以參考下2017-09-09mybatis框架之mybatis中dao層開發(fā)的兩種方法
這篇文章主要介紹了mybatis框架之mybatis中dao層開發(fā)的兩種方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-07-07