Spring-mybatis.xml
<aop:aspectj-autoproxy />
LogAdvice.java
@Aspect @Component public class LogAdvice { //可复用的植入点,方法名method为引用 @Pointcut("execution(* com.ssm..*.transferMoneyByProcedure(..))") void method() {} @Before("execution(public void com.ssm.dao.UserDao.transferMoney(*))" before(){ System.err.println("Spring AOP before method...."); } @AfterReturning("method()" after() { System.err.println("Spring AOP after method...."); } @AfterThrowing("method()" exception() { System.err.println("Spring AOP throws Exception...."); } @Around("method()"void around(ProceedingJoinPoint point) throws Throwable { System.err.println("String AOP around start...."); point.proceed(); System.err.println("String AOP around end...."); } }
pom.xml
dependency> groupId>org.aspectj</artifactId>aspectjweaverversion>1.8.7> >