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:
<jvmArguments>
-agentlib:native-image-agent=config-output-dir=target/native-image
</jvmArguments>
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:
Project
|__src
|__main
|__java
|__resources
|__META-INF
|__native-image <-- Put the configuration files in this folder
Then start the native image build again: mvn -DskipTests -Pnative clean package
If you run the binary, the exception should be gone.