I'm trying to build native image of my SpringBoot 3 app with generated configuration from agent of native-image-agent
My steps I currently do:
- Building of .jar: mvn -DskipTests spring-boot:run with jvmArgs which provided in maven configuration:
<jvmArguments>
-agentlib:native-image-agent=config-output-dir=target/native-image
</jvmArguments>
- Next step is I remove jvmArgument which builds configuration and run command which builds native image: mvn -DskipTests -Pnative clean package
In generated reflect-config.json of the first step I can find configuration for HikariConfig class and method setConnectionTimeout(long ms), but when I try to run generated in second step native image I can see this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonDataSource': Runtime reflection is not supported for public void com.zaxxer.hikari.HikariConfig.setConnectionTimeout(long)
Seems that this configuration is not loaded during native image build. Probably I should set some config path variable or put config to some folder, could you help me please?
The configuration files generated by the Tracing Agent must be put under
META-INF/native-image
(as described here).Your project structure should look like this:
Then start the native image build again:
mvn -DskipTests -Pnative clean package
If you run the binary, the exception should be gone.