Search code examples
spring-bootspring-native

spring native generation with multi module maven application


I am trying to use the native image generation present in the experimental branch of spring boot, and i am having some issues with my multi-module application.

I have 2 jars that need to be built and one executable module that includes those 2 jars, and according to their example/documentation, i should only use the native/aop plugins only on the module that contains the Application class.

However if i do that, for one of the modules for which i also need to generate some openapi dependencies, i am getting the "org.springframework.util.unit.DataSize was unintentionally initialized at build time." error, which usually means you need to use those plugins in the module's pom. If i do that, it will also generate a native image for that module, which will fail because it doesn't really have an entry point. I suspect needing to execute the openapi generator inside might be the culprit.

Anyone has any examples of successful multi-module spring native applications?


Solution

  • The issue was in fact that you need to apply the spring native image plugins only on the module that contains the entry point class (Application.java). Also, if you ever want to use spring native, DO USE the agent to automatically detect all the reflection and proxying happening in your application, it really helps.