DEV Community

Chaitanya Chunduri
Chaitanya Chunduri

Posted on

1

About Spring Boot Native Images

I was recently impressed by Spring Boot's native images feature. I considered sharing some information about native images.

I created two simple Spring Boot projects
1) spring-with-native-plugin
2) spring-without-native-plugin

Apart from the Main class, I used the same controller in both projects.

Hello World Controller

I used the following command to create docker images.

mvn spring-boot:build-image 
Enter fullscreen mode Exit fullscreen mode

(Both projects are based on maven)

When I ran both docker images, I was surprised by the application startup time.

Spring-Without-native

Spring-with-native

There's also a significant difference in the sizes of the two Docker images.

memory-deference

So, What happened after we installed the native plugin?

  • Thanks to Spring AOT Process, it performed a code analysis to identify unnecessary code.
  • After the code analysis, all unnecessary code was removed, and a native image was created.

Now, This native image is no longer dependent on the JVM and can run without the JVM.

We must thank @graalvmfor making this all possible.

AWS Q Developer image

Your AI Code Assistant

Implement features, document your code, or refactor your projects.
Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay