IntelliJ IDEA查找Java项目中,没有使用事务的类和方法

IntelliJ IDEA查找Java项目中,没有使用事务的类和方法

        final StopWatch sw = new StopWatch();// 扫描注解注册
        sw.start();
        final Reflections reflections = new Reflections("com.example.demo.service.impl");
        Set> theFoos = reflections.getTypesAnnotatedWith(Service.class);
        LOGGER.debug("==========实现类个数:{}",theFoos.size());
        for(Class cz:theFoos){
            Method[] mm = cz.getDeclaredMethods();
            for(Method m:mm){
                if(Modifier.isPublic(m.getModifiers())){//公共方法
                    Annotation[] anns = m.getDeclaredAnnotations();
                    List as = new ArrayList<>();
                    for(Annotation a:anns){
                        as.add(a.annotationType().getName());
                    }
                    if(!as.contains(Transactional.class.getName())){
                        LOGGER.debug("==========class:{} 没有 Transactional 注解, 方法:{}",cz.toString(),m.getName());
                    }
                }
            }
        }

        sw.stop();

运行效果为:

IntelliJ IDEA查找Java项目中,没有使用事务的类和方法_第1张图片 

项目详情,请参考http://www.zrscsoft.com/sitepic/12103.html

 

你可能感兴趣的:(JAVA)