2

On startup of a spring-boot application I want to perform a scan for all @Entitiy classes on the classpath.

Moreover, I'd like to filter any entities with a @CustomAnnotation.

I want to create some kind of auto configuration, and use the package of any entities found in:

EntityManagerFactoryBuilder
  .dataSource(ds)
  .packages(getPackages()))

But I don't want to explicit define the package there the appropriate entities are to be found, but find them on startup. Is that possible at all?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

2 Answers2

1

I don't know the answer but in order to have the annotations on the compiled class files, they must be defined as follows @Retention(RetentionPolicy.RUNTIME)

Fran Montero
  • 1,679
  • 12
  • 24
0

You can use the java-reflections library to search for annotated classes, methods or classes extending another class across all loaded class files

Rene8888
  • 199
  • 2
  • 12