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
  • 74,158
  • 163
  • 522
  • 986

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,601
  • 11
  • 23
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