Setting up a spring-native application in spring-boot-3
Some time ago, Spring Boot 3 was released. Spring Boot 3 introduced the official support for Spring-Native, which provides support for compiling Spring applications to native executables using the GraalVMnative-image
compiler.
Compared to the Java Virtual Machine, native images can enable cheaper and more sustainable hosting for many types of workloads. These include microservices, function workloads, well suited to containers and Kubernetes
.
Now it is time to see what we can do with it. Let’s try to find out if that really works and how time-consuming the build is.
Starting by reading the Spring-Native Docs
and setting up an example hello-world application.
The next step ist do get the basic spring-application. On Spring Initilzr
I select:
Project: Gradle - Groovy
Language: Java
Spring Boot: 3.0.1
Packaging: Jar
Java: 17
Dependencies: GraalVM Native Support
Make a change to the output
To see if it really works I go to the DemoApplication and change the following line to:
publicstaticvoidmain(String[] args){ SpringApplication.run(DemoApplication.class, args); System.out.println("Hurra this is a short test.");}
Pre-Build
Before building check that JAVA_HOME ist set, else you’ll get: "Cannot query the value of property 'javaLauncher' because it has no value available."
You need gcc installed (sudo apt install gcc), else you’ll get "Error: Default native-compiler executable 'gcc' not found via environment variable PATH"
try to run it locally: ./build/native/nativeCompile/demo
Conclusion
It was possible to set up a Spring Boot 3 project with the help of the Spring Initialzer. Compiling worked for
the first project on a Mac and the demo-program started out of the box. The build is quite time-consuming but
not as long as I’ve heard from other people. It took less than a minute for the demo application.
What impact will AI have on the work of agile teams in software development? Will we be supplemented by tools or will Agent Smith take over? In the following article, we strive to get an overview of current developments and trends in AI and how agent-based workflows could change the way we work.
Discover how Angular 15's shift from class-based to functional route guards changes the game for developers, offering a more flexible approach to securing applications. However, this transition brings its own set of challenges, especially when it comes to unit testing.