使用特定程序包中的注释进行注释的方法之前的切入点

时间:2018-11-07 15:50:29

标签: java spring aspectj

在AspectJ中,我想在特定方法调用之前创建切入点。 这些方法是:

  • 在REST Web控制器中
  • 使用 org.springframework.web.bind.annotation 包中的注释进行注释,该注释的名称以“ Mapping ”结尾(例如:org.springframework.web。 bind.annotation.PostMapping)。

我创建了以下课程:

@Aspect
@Component
@Slf4j
public class TestAspect {

    @Before("within(@org.springframework.web.bind.annotation.RestController *) && @annotation(org.springframework.web.bind.annotation.PostMapping)")
    public void beforeMethod(JoinPoint joinPoint){
        log.debug("Before method {}", joinPoint.getSignature().getName());
    }

}

它运作良好,但我想对其他 Mapping 注释执行相同的操作。 “ @annotation ”属性不接受模式作为值,不允许使用@annotation(org.springframework.web.bind.annotation。*)。

在没有为包的每个 Mapping 注释重复' @annotation '属性的情况下,该怎么做?

0 个答案:

没有答案
相关问题