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?

How hot deployment works.

Ways to create Quarkus application

Prerequisites

An IDE
JDK 1.8+ installed with JAVA_HOME
Apache maven 3.6.2+
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

quarkus.http.port=8080
%prod.quarkus.http.port=9090
%<environemnt-name>.<property-name>=<proeprty-value>
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
@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;

...
}

--

--

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