我能找到的最好方法如下:只需覆盖这样的bindInterceptor方法.
匹配:
public final class NoSyntheticMethodMatcher extends AbstractMatcher<Method> {
public static final NoSyntheticMethodMatcher INSTANCE = new NoSyntheticMethodMatcher();
private NoSyntheticMethodMatcher() {}
@Override
public boolean matches(Method method) {
return !method.isSynthetic();
}
}
Run Code Online (Sandbox Code Playgroud)
bindInterceptor方法:
@Override
protected void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors) {
super.bindInterceptor(classMatcher, NoSyntheticMethodMatcher.INSTANCE.and(methodMatcher), interceptors);
}
Run Code Online (Sandbox Code Playgroud)
但解决方案并不总是有效.就像在我的情况下,目标JpaPersistModule是最终的,我可以覆盖该方法的唯一方法是复制粘贴实现.
| 归档时间: |
|
| 查看次数: |
1912 次 |
| 最近记录: |