栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

dubbo filter 中获取接口上注解 is null

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

dubbo filter 中获取接口上注解 is null

在我的实现MyLogFilter 的方法中。想得到这个注解 myAnnotation 对象却一直为null。

@Slf4j
@Activate(group = {Constants.PROVIDER}, order = 1000)
public class MyLogFilter implements Filter {

    @SneakyThrows
    @Override
    public Result invoke(Invoker invoker, Invocation invocation) throws RpcException {

       MyAnnotation myAnnotation = invoker.getInterface().getAnnotation(MyAnnotation.class);
}

经过分析,Spring在处理中,可能是因为我的项目有事务,serviceImpl的方法被代理后直接得不到了。换一个思路:先得到自己的父类,然后通过父类得到真实的自己

        String methodName = invocation.getMethodName();

        Method declaredMethod = invocation.getClass().getDeclaredMethod(methodName, invocation.getParameterTypes());

        MyAnnotation annotation = declaredMethod.getAnnotation(MyAnnotation.class);
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/922084.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号