What
Spring boot uses AOT processing to generate required reflect/proxy/resource configs as well as CGLIB proxy classes in compile time. For beans defined with interface types, CGLIB proxy is usually unnecessary so process-aot job does not generate CGLIB proxy.
When org.springframework.data:spring-data-mongodb is imported, java native projects with repository beans defined with interface types will encounter exception in runtime about unexpected CGLIB usage for the repository class.
Update: upon further investigation, just having org.springframework:spring-tx is enough to trigger the issue. It's not directly caused by spring-data-mongodb.
Minimum reproduciable project
https://github.com/jzhn/springNativeBugSpringDataMongoDB. Please refer to its README for steps to reproduce, expected behaviour and actual behaviour.
Versions
- JDK:
21.0.2-graalce
- Spring-Boot:
3.4.2 (latest to date)
- MacOS
15.2 on ARM64 mac