I can use org.reflection to get package classes using wildcard?

前端 未结 1 1031
一个人的身影
一个人的身影 2021-01-27 23:38

I was using

Reflections reflections = new Reflections(\"com.mypackage.root\", new MethodAnnotationsScanner()); 

But with this aproach i get ba

相关标签:
1条回答
  • 2021-01-28 00:26

    Try

    Reflections reflections = new Reflections("com.mypackage.root", new MethodAnnotationsScanner());
    
    Set<Method> methods = reflections
            .getMethodsAnnotatedWith(MyAnnotation.class).stream()
            .filter(method -> method.getDeclaringClass().getPackage().getName().matches("com.mypackage.root.*.deep"))
            .collect(Collectors.toSet());
    
    0 讨论(0)
提交回复
热议问题