dimanche 25 avril 2021

How to scan for annotations in methods only in specific classes using reflection library java?

I have an annotation @API which I assign to all the routes i.e RequestMapping in a controller in java spring.What I want to do is,First scan all the classes in a package that are annotated with @Controller and after scanning all the controller classes,I want only to scan for Methods with annotation @API in only these controller annotated classes.

How can I implement this in using reflection in java?

  Reflections reflections = new Reflections("my.project.prefix");

  Set<Class<? extends SomeType>> subTypes = reflections.getSubTypesOf(SomeType.class);




Aucun commentaire:

Enregistrer un commentaire