javaEEday12-AOP进阶-切入点表达式-execution---1
This commit is contained in:
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Aspect
|
||||
//@Aspect
|
||||
@Order(3)
|
||||
public class MyAspect3 {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Aspect
|
||||
//@Aspect
|
||||
@Order(2)
|
||||
public class MyAspect4 {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Aspect
|
||||
//@Aspect
|
||||
@Order(1) //用来控制多个切面类谁先执行的操作
|
||||
public class MyAspect5 {
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.inmind.aop;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
//切面类
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class MyAspect6 {
|
||||
|
||||
// @Pointcut("execution(public void com.inmind.service.impl.DeptServiceImpl.deleteDept(java.lang.Integer))")
|
||||
// @Pointcut("execution(void deleteDept(java.lang.Integer))")
|
||||
// @Pointcut("execution(* com.inmind.service.impl.DeptServiceImpl.deleteDept(java.lang.Integer))")
|
||||
// @Pointcut("execution(* com.inmind..DeptServiceImpl.deleteDept(java.lang.Integer))")//..表示任意层级的包
|
||||
// @Pointcut("execution(* com.inmind..DeptServiceImpl.delete*(java.lang.Integer))")//delete*表示匹配以delete开头的任意方法
|
||||
// @Pointcut("execution(* com.inmind..DeptServiceImpl.delete*(..))")//(..)表示是任意个数任意类型的参数列表
|
||||
@Pointcut("execution(* delete*(..))")//此处表示所有方法
|
||||
private void pt(){}
|
||||
|
||||
@Before("pt()")
|
||||
public void before(){
|
||||
log.info("MyAspect6 ... before ...");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
@Transactional(rollbackFor = Exception.class)//让当前方法,处于事务管理下(在方法调用前,执行start transaction)
|
||||
@Override
|
||||
public void deleteDept(Integer id) throws Exception {
|
||||
|
||||
deptMapper.deleteDept(id);
|
||||
}
|
||||
|
||||
//新增部门
|
||||
|
||||
Reference in New Issue
Block a user