Spring AOP
Posted alwaysbecoding
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring AOP相关的知识,希望对你有一定的参考价值。
<?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.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"> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="find*" read-only="true" /> <tx:method name="query*" read-only="true" /> <tx:method name="get*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(* org.mx..dao.I*Dao.*(..))" id="daoMethods" /> <aop:pointcut expression="execution(* org.mx..task.I*Task.*(..))" id="taskMethods" /> <aop:pointcut expression="execution(* com.business..I*Business.*(..))" id="businessMethods" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="taskMethods" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="businessMethods" /> <aop:aspect id="LogAspect" ref="LogAspectBean"> <aop:pointcut expression="execution(* org.mx..task.I*Task.*(..))" id="logsPointCut" /> <aop:pointcut expression="execution(* com.business.I*Business.*(..))" id="logsPointCutBusiness" /> <aop:around pointcut-ref="logsPointCut" method="businessLogAround" /> <aop:around pointcut-ref="logsPointCutBusiness" method="businessLogAround" /> </aop:aspect> </aop:config> </beans>
以上是关于Spring AOP的主要内容,如果未能解决你的问题,请参考以下文章