How to build a list of classes annotated with my custom annotation?

后端 未结 8 1153
梦毁少年i
梦毁少年i 2020-12-23 16:52

I want to get a complete list of classes in the application which are annotated with @Custom annotation. What is the best mechanism for this operation?

8条回答
  •  清歌不尽
    2020-12-23 17:14

    I know this is an old question, but I ran across it in my own search for classpath scanning and found another good answer, so I'm adding it here.

    Google Guava has a ClassPath object that provides "best effort" classpath scanning (which is all any classpath scanning utility offers, really). Since Guava is a widely-adopted, carefully-maintained utility library, this is a great option for projects that either (a) are already using Guava, or (b) need a stable library they can rely on for classpath scanning.

提交回复
热议问题