AspectJ 碰到的一个问题

在使用切面的时候碰到一个问题,

在Controller方法上加上 注解,然后再添加了dispatchService 的 @PostConstruct 注解,如下:

 @PostConstruct
    public void findAllExeRequestMethods() {
        final Map<String, Object> beans = getContext().getBeansWithAnnotation(ExeController.class);
        for (final Map.Entry<String, Object> entry : beans.entrySet()) {
            for (final Method method : entry.getValue().getClass().getDeclaredMethods()) {
                final ExeRequest req = method.getAnnotation(ExeRequest.class);
                if (null != req) {
                    final RequestType reqType = req.value();
                    getMethodMap().put(reqType, method);
                    services.put(reqType, entry.getKey());
                }
            }
        }
    }

 然后,对其中的ExeRequest注解,进行切面处理

比如:

@around, @Before 等

会导致上面的方法中 method 的annotation 值为空,只要切面一加就会这样,本来打算对注解做处理的

现在只能另寻他路

还不明白原因在哪里

猜你喜欢

转载自patrick002.iteye.com/blog/2197620