Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Aspectj@Before起作用,但@Pointcut不起作用_Spring Boot_Aspectj - Fatal编程技术网

Spring boot Aspectj@Before起作用,但@Pointcut不起作用

Spring boot Aspectj@Before起作用,但@Pointcut不起作用,spring-boot,aspectj,Spring Boot,Aspectj,我有一个在spring boot应用程序中实现aspectj的简单示例,我正在尝试让每个不同的方法都能工作 如果我使用下面的 @Before("execution(* com.example.test.controllers.ProductController.deleteProduct(..))") public void specificInterception() { System.out.println("pointcut interception working");

我有一个在spring boot应用程序中实现aspectj的简单示例,我正在尝试让每个不同的方法都能工作

如果我使用下面的

  @Before("execution(* com.example.test.controllers.ProductController.deleteProduct(..))")
  public void specificInterception() {
    System.out.println("pointcut interception working");
  }
这很好,我可以看到控制台输出的
println

然而,如果我使用

  @Pointcut("execution(* com.example.test.controllers.ProductController.deleteProduct(..))")
  public void specificInterception() {
    System.out.println("pointcut interception working");
  }

它无法触发。为什么这不起作用?

一个单独用
@Pointcut
注释的方法没有任何作用。它只允许多次重复使用同一表达式,而不必重新声明它。我甚至不确定这样一个方法的方法体是否会被调用

在您的情况下,您可以像这样使用切入点:

@Pointcut(“执行(*com.example.test.controllers.ProductController.deleteProduct(..))
public void specific切入点(){}
@在(“specificPointcut()”)之前
公共网络拦截(){
System.out.println(“切入点拦截工作”);
}

一个单独用
@Pointcut
注释的方法不会做任何事情。它只允许多次重复使用同一表达式,而不必重新声明它。我甚至不确定这样一个方法的方法体是否会被调用

在您的情况下,您可以像这样使用切入点:

@Pointcut(“执行(*com.example.test.controllers.ProductController.deleteProduct(..))
public void specific切入点(){}
@在(“specificPointcut()”)之前
公共网络拦截(){
System.out.println(“切入点拦截工作”);
}