Java World: Quarkus with Spring Boot

Introduction:

The Java ecosystem remains a frequent corporate choice for new projects where technological maturity is important. Perhaps the number of companies known as startups that start projects with Java is not so high, but certainly the platform remains a frequent choice in new projects of large corporations that seek innovation and that seek to do what is considered “digital transformation”.

But let’s be honest, some frameworks that have evolved into complete ecosystems have helped the Java language to stay on top of the most used technologies in the world.

In the new world of microservices, Spring Boot managed to keep Java very active in several projects of the most varied types of business, finance, e-commerce, retail…
But competition has also increased, as cloud provider costs are now a reality for companies to face. Languages ​​that consume less computational resources will always be considered and even with the excellence of Spring, Java did not have that much advantage in this respect.

As the ecosystem and the Java community seem to have some good antifragility level, the problems and possible disadvantages of the Java platform were one of the main reasons for the creation of Quarkus.

So if you have read about how efficient Quarkus can be but like me, you know the countless qualities and enjoy working with Spring Boot, let’s see here how we can use the way of programming with Spring, using the efficiency of Quarkus.

This integration between Quarkus and Spring Boot is still in its initial phase, it is up to us developers to monitor the Quarkus project to see if there will be any evolution in this approach.

The example project:

A simple API Rest with GET and POST methods using Quarkus, but with Spring Boot’s annotations and design.

Practice:

First: You need the Java SDK 11 (or OpenJDK) and Maven ready to use in your computer.

In your browser, access:
https://code.quarkus.io/
Look for the Compatibility extensions and select Spring DI and Spring Web API.

Example in the image below:

Click the Generate Your Application button. This will generate a .zip file with the initial code for your sample application.
Open or import the maven code into your favorite IDE.

Java Classes:

After import your project on IDE, you have a Java class/file SpringGreetingController.java

You can modify this file with the code below:

This code is an example, there is not a database then our method save() and find() is only a “mock”.
Now, you can create a new class GreetingService.java with the code below:

In the root directory of your application you can execute the following command:
mvn compile quarkus: dev

Testing the application working:

Access http://localhost:8080 in your browser:

Testing GET and POST methods (with Postman or other tool of your preference):

GET (path: http://localhost:8080/quarkus-spring):

POST (path: http://localhost:8080/quarkus-spring):

Conclusion:

We finished. If you already know the basics of Spring Boot, you certainly recognized the annotations that were used for the creation of the simple API Rest and for Dependency Injection. However, this is not a Java application with Spring, but Quarkus.
Quarkus also offers the use of Spring annotations such as:
Spring Data JPA, Spring Cloud Config Client, Spring Security and others.

Visit my page for online courses:

https://learncodeclub.systeme.io/

--

--

--

Software Developer || Technology Researcher || Very interested in economics and general aspects of society

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Iota’s Qubic broken down for kids

Director, Deputy Director, Office Secretary-I & Other — 12 Posts

F# Mentorship — Week 1

An Introduction to Flask: A micro-framework

Why Engineers Suck at Building Great Products

Best way to learn Bot Development 📺💻📱👀

Dice simulation using python-OOP

GSoC’21 Week 2: Lint lint lint

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinícius Pereira de Oliveira

Vinícius Pereira de Oliveira

Software Developer || Technology Researcher || Very interested in economics and general aspects of society

More from Medium

Spring Cloud Gateway — Request filtering and redirection

Monitoring Spring Boot Applications: Part 1

Upload KMS key encrypted object from AWS S3 using AWS SDK 2.x for Java

MICROSERVICES IN SPRING BOOT I