Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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 AOP-建议在子类中未重写超类方法_Spring_Aop_Spring Aop - Fatal编程技术网

Spring AOP-建议在子类中未重写超类方法

Spring AOP-建议在子类中未重写超类方法,spring,aop,spring-aop,Spring,Aop,Spring Aop,但是, 如何在不覆盖CService中的needsToBeAdvised()的情况下实现这一点 编辑: 我应该补充一点,BService和CService都在同一个包中 如果我将切点更改为以下内容: cService.needsToBeAdvised(cParam) //is NOT. 它工作的唯一方法是在CService中重写需要被警告()?根据您的示例代码,我怀疑a服务和b服务在包包中,但c服务在另一个包中。如果服务确实在不同的包中,您可以选择: 移动以使它们位于同一个包中 将您的切入点

但是,

如何在不覆盖
CService
中的
needsToBeAdvised()
的情况下实现这一点

编辑:

我应该补充一点,
BService
CService
都在同一个包中

如果我将切点更改为以下内容:

cService.needsToBeAdvised(cParam) //is NOT.

它工作的唯一方法是在
CService

中重写
需要被警告()?根据您的示例代码,我怀疑
a服务
b服务
包中,但
c服务
在另一个包中。如果服务确实在不同的包中,您可以选择:

  • 移动以使它们位于同一个包中
  • 将您的切入点更改为更通用的切入点,例如执行(**.A+.needsToBeAdvised(*)
  • 添加更多切入点

  • 感谢您的回复。它们在同一个软件包中。请参见上面的编辑。
    bService.needsToBeAdvised(bParam) //is intercepted
    
    cService.needsToBeAdvised(cParam) //is NOT.
    
    @Pointcut("execution(* package.CService.needsToBeAdvised(*))")
    
    cService.needsToBeAdvised(cParam) //is still not intercepted