DEV Community

özkan pakdil
özkan pakdil

Posted on • Originally published at ozkanpakdil.github.io on

How to build spring boot native binary

In short, I am explaining why we should use ./mvnw -Pnative native:compile and what error comes otherwise and why.

I was preparing this answer. And I was having problem with the class not found errors while building because I was using this command

./mvnw native:compile
...
Error: Please specify class (or <module>/<mainclass>) containing the main entry point method. (see --help)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.448 s
[INFO] Finished at: 2024-09-01T21:24:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.10.2:compile (default-cli) on project env-variables: Execution of C:\sdkman\candidates\java\21.0.2-graal\bin\native-image.cmd @target\tmp\native-image-2373453772169200185.args returned non-zero result -> [Help 1]
[ERROR]

Enter fullscreen mode Exit fullscreen mode

Then remembered the profile thing and finally get rid of this error, used below command

./mvnw -Pnative native:compile

Enter fullscreen mode Exit fullscreen mode

that actually trigger spring-boot:process-aot that creates the required configuration for graalvm to build the project for native binary. Check this page for details.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay