Migrating Spring boot web application to Quarkus.

abhiroop ghatak
6 min readDec 24, 2020

Analyze compute footprint by deploying in Openshift — To read in Part2

Executive Overview: We all agree cloud is the new ground for web applications to execute and it has different manifesto e.g. majorly stateless, elastic, resilient and functionalities (services) exposed to network. Different technology vendors adapt the above and provide technologies (tools & libraries) to developers to develop application for cloud. From java tech stack Spring boot is primary one to develop microservices. Recently there is new player comes into this horizon with community support named QUARKUS. This paper describes Quarkus a little and migrate an existing spring boot application to Quarkus runtime based , deploy all in Red Hat openshift and analyze the difference among the two to decide the which one to adapt for our next java based microservice development.

QUARKUS — Brief: They say “Quarkus tailors your application for GraalVM and HotSpot. Amazingly fast boot time, incredibly low RSS memory (not just heap size!) offering near instant scale up and high-density memory utilization in container orchestration platforms like Kubernetes.”

Quarkus is intended for building lightweight, container-based microservices and server less applications. Inclusion in Runtimes gives enterprise customers a version of the open source Java stack that is supported by Red Hat. In short, it claims services developed using Quarkus uses less memory, file IO, fast and very minimal startup time. We will do and check the same .

Use Case:

Heard about Quarkus and about its claims, but is that easy to go the Quarkus way? One way is greenfield projects to develop services from ground zero. Other use case is majorly we have spring boot developers and applications already developed in spring boot. So, can we migrate from spring boot to Quarkus? is it hard to migrate an existing app? For sure in a hello world demo this will look fantastic (they all look that way, don’t they?) but, in a real app, is that nice? is that easy? is that fun? In this paper, I will show my experience in migrating an app to Quarkus, which is spring boot based and uses different technologies as angular UI, Hibernate, Rest, …etc.

Existing Spring boot Application:

Here for our demo purpose we have selected a user profile management type application, which consists of two microservice i.e. emart-frontend & emart-backend.

Both the service is spring boot application where frontend app uses angular js, bootstrap for web pages and spring controller to receive /parse http request and per business logic connect backend microservice via rest call uses spring restTemplate to do the same. It maintains model Pojo to consume backend data and return it to angular to process and draw dynamic web page.

It also works with circuit break pattern and check backend service availability before passing web request to process at backend. On unavailability of backend service it block further request propagation instead show message at front end. The backend app is Rest JPA, hibernate based and uses h2 (in memory) database for sql demo part. Below snippet is from backed service pom.xml file.

Migration of Spring boot Application: For this demo exercise, we will convert the emart-front end app to Quarkus based and while in deploy we will connect same backend service. To analyze compute footprint, we will deploy all three-micro service in Red Hat Openshift where both front-end app (spring & Quarkus based) will connect same backend and provide same functionality.

Migration Steps:

  1. Checkout the spring boot front end app and import in any IDE of your choice. In our case snapshots are from springSourceToolSuite IDE. Rename project to labelled as Quarkus one.
On the left is the original spring app , on the right the app in migration

2.Add Quarkus elements to the pom.xml i.e. add the below block containing all major version of Quarkus dependencies in pom file.

3. Modify pom file for dependencies. Remove spring boot deps and add related Quarkus spring extension dependencies.

On the left is the original spring app , on the right the app in migration

4.Add the Quarkus-maven-plugin under the build configuration:

5. Application code migration: At this stage maven pom is all set and now we will change little coding in the application side. All first Quarkus app does not need explicit main function code that we have in spring boot app where we initiate app i.e. SpringApplication.run. So, in Quarkus app remove the same. To connect with backend service in Quarkus we register a rest client (as spring restTemplate is not supported here) and that we did in a new interface BackendServiceConsumer.java Below is snippet from the same. This technology is adopted in Quarkus from micro profile.

6. Analyze errors in java classes due to above code & pom changes: Changing in Maven pom generates few import errors in existing classes as they do not have the spring specific dependencies and so the jars in their class file. Our next step should be to find Quarkus substitute of them and replace with the same. e.g. in controller class Rest method type and media type import statement changes to javax.ws.rs.* . And functions where it connects backend using restTemplate needs to change to using rest-client of Quarkus. The interface we discussed above.

7. Application Property changes: In spring boot app we have used one property service.emart.url in application.properties file with the backend service root url and access that value with @Value annotation (@Value(“${service.emart.url}”)) in controller file to connect the backend service. In Quarkus we have used micro profile restclient and they have little different mechanism to provide that property, which is to provide class full name with mp-rest/url.


Also, if you want a particular port for your application, instead of server.port you need to use quarkus.http.port for the same.

8. Static page location update: Quarkus and spring uses different default location for their static components (html, css etc). In our springboot app the html page is kept inside src/main/resources/static folder but in Quarkus application you need to update the same as Quarkus static resolver, by default lookup content inside src/main/resources/META-INF/resources.

9. Test and verify application in local: Once all compile error and IDE suggestions are rectified then it is time to verify the apps and connectivity in local before deploying in cloud. Run Quarkus application in local in dev mode. Use below command to do the same and verify application.

>> mvn compile quarkus:dev

Part 1 ends here . The complete code can be checked out @ HERE.

To read continue , click .



abhiroop ghatak

Cloud Developer Advocate. Post Graduate in Computer Applications with 11+ years of experience in Software Development & cloud onboarding.