如何创建切入点来伪装支持接口继承的客户端?

How to create pointcut to feign client that supports interface inheritance?

在一个 Spring 引导项目中我有一个简单的假客户端

@MyAnnotation
@FeignClient(name="some-name", url="http://test.url")
public interface MyClient {
    @RequestMapping(method = RequestMethod.GET, value = "/endpoint")
    List<Store> getSomething();
}

我需要拦截所有调用,为此我正在创建一个可用于不同项目的通用库。为了实现它,我尝试使用 Spring AOP。我创建了一个方面,它包装了用 MyAnnotation

注释的对象的所有 public 方法
@Around("@within(MyAnnotation) && execution(public * *(..))")
public Object myWrapper(ProceedingJoinPoint invocation) throws Throwable {
   // ...
}

它工作正常,所有调用都被拦截,直到我尝试将 MyAnnotation 放在使用假接口继承的假客户端上。当我用继承的接口初始化我的客户端时,调用不再被拦截。

public interface FeignClientInterface {
    @RequestMapping(method = RequestMethod.GET, value = "/endpoint")
    List<Store> getSomething();
}

@MyAnnotation
@FeignClient(name="some-name", url="http://test.url")
public interface MyClient extends FeignClientInterface{ 
}

我试过了:

问题是如何在不将 @MyAnnotation 移动到基本界面 FeignClientInterface 的情况下使其工作。它在另一个项目中,我无法控制它。

好的,经过几个小时的调查,我用这个替换了我的切入点

@Around("execution(* (@MyAnnotation *).*(..)) || execution(@MyAnnotation * *(..))")

正如所解释的 here 我只使用 execution 来避免创建代理。