spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

"java.lang.IllegalArgumentException: Not a managed type: class ..." in spring-native image when entity not in same package hierarchy as app #1678

Closed thejames97 closed 2 years ago

thejames97 commented 2 years ago

When running as native image the framework throws "Not a managed type" exception on my Entity when my Entity class is not in the same package hierarchy as the application class, even though I've specified the package where the Entity is in the @EntityScan annotation. The app starts up and works fine in JVM mode. It also starts up and works fine in the native image when I move the Entity class to a sub-package of the application class. But this is not always possible (or even desirable).

Reproducer app: https://github.com/thejames97/spring-native-bug

snicoll commented 2 years ago

Thanks for the reproducer. Spring Native is fairly limited in what it does there and is based on the components indexer (that main component scan directive). We're taking this code over and we'll look at honoring @EntityScanso that the sample works as expected.