Understanding the power of Quarkus

Quarkus vs Spring boot

1. Start-up time :

2. Memory footprint

But How Quarkus is so fast and light-weight?

  1. Compiling
  2. Startup

How hot deployment works.

Ways to create Quarkus application

Prerequisites

An IDE
JDK 1.8+ installed with JAVA_HOME
Apache maven 3.6.2+

Online

Using maven command

mvn io.quarkus:quarkus-maven-plugin:1.5.2.Final:create
mvn io.quarkus:quarkus-maven-plugin:1.5.2.Final:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=lifecycle-quickstart \
-DclassName="org.acme.lifecycle.GreetingResource" \
-Dpath="/hello"

No main class

@QuarkusMain
public class Main {
public static void main(String... args) {
Quarkus.run(MyApp.class, args);
}
public static class MyApp implements QuarkusApplication {
@Override
public int run(String... args) throws Exception {
System.out.println("Do startup logic here");
Quarkus.waitForExit();
return 0;
}
}
}

First Rest API

mvn compile quarkus:dev
mvn package
java -jar target/<jar-name>.jar

Swagger

<dependency>
<groupid>io.quarkus</groupid>
<artifactId>quarkus-smallrye-openapi</artifactid>
</dependency>
http://localhost:8080/swagger-ui/
http://localhost:8080/openapi

Special 404 page

Property file

Properties of multiple environments

quarkus.http.port=8080
%prod.quarkus.http.port=9090
%<environemnt-name>.<property-name>=<proeprty-value>

Other properties we can define in the application.properties file

quarkus.datasource.url=jdbc:postgresql:test_db
quarkus.datasource.driver=org.postgresql.Driver
quarkus.datasource.username=root
quarkus.datasource.password=root
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.log.sql=true
quarkus.log.level=INFO
quarkus.log.category."org.hibernate".level=DEBUG
# Other log levels FATAL, ERROR, DEBUG, INFO, WARN, TRACE
student.firstname=foo
student.lastname=bar
student.age=26

Accessing properties

@ConfigProperty(name = "student.firstname")
String name;
@ConfigProperty(name = "student.firstname", defaultValue = "mat")
String name;
import io.quarkus.arc.config.ConfigProperties;@ConfigProperties(prefix = "student")
public class Student {
private String firstname;
private String lastname;
private Integer age;

...
}

--

--

--

Full stack developer

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

Recommended from Medium

Setting up Podman on WSL2 in Windows 10

Tmuxinator Config File Generator

Sample tmux session preview

“Dress for success: Contribute to Open Source” — Code Inspector Talks!

Decomposition of Enterprise legacy systems into microservices

An artesian view

Easy Setup for a Node website with AWS EC2

Building scalable Pipeline with Azure DevOps

GURUFIN official channels

A quick introduction to using Git/Github — ADD, COMMIT, PUSH

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
Rohan Aggarwal

Rohan Aggarwal

Full stack developer

More from Medium

Limit of builder pattern in object composition

Springboot — Test DAO/Repository layer with no main class in the library using Junit5.

JDK 18 and the UTF-8 as default charset

Print names of test methods executed by JUnit 5