Quarkus + Maven Hello World Example
Hello everyone, Today we will learn how how to engender a Maven + Quarkus hello world project.
More Quarkus Related topics,
- Quarkus + Angular 10 + MongoDB CRUD Example
- Quarkus + React JS + MongoDB CRUD Example
- Quarkus + Vue.js + MongoDB CRUD Example
- Build Reactive CRUD APIs With Quarkus, MongoDB, and Panache
- QUARKUS + Hibernate CRUD example - Creating a CRUD REST API/Service
- Build REST CRUD APIs with Quarkus and MyBatis
- Build Rest CRUD API with Mongodb, Quarkus, and Mongodb Client
- Build Rest CRUD API with Quarkus and MongoDB Panache
- Create Quarkus Project With code.quarkus.io: Hello world example
- Quarkus + FreeMarker + Hibernate - CRUD example
- Quarkus File Upload Example
- Quarkus - How to send email via SMTP - Quickstart
- Quarkus - Qute - Hello World Example
- Quarkus + Maven Hello World Example
- Configuring the HTTP Port on Quarkus Applications
- Quarkus - Interview questions and answers
- Quarkus + Angular 10 + MongoDB CRUD Example
- Quarkus + React JS + MongoDB CRUD Example
- Quarkus + Vue.js + MongoDB CRUD Example
- Build Reactive CRUD APIs With Quarkus, MongoDB, and Panache
- QUARKUS + Hibernate CRUD example - Creating a CRUD REST API/Service
- Build REST CRUD APIs with Quarkus and MyBatis
- Build Rest CRUD API with Mongodb, Quarkus, and Mongodb Client
- Build Rest CRUD API with Quarkus and MongoDB Panache
- Create Quarkus Project With code.quarkus.io: Hello world example
- Quarkus + FreeMarker + Hibernate - CRUD example
- Quarkus File Upload Example
- Quarkus - How to send email via SMTP - Quickstart
- Quarkus - Qute - Hello World Example
- Quarkus + Maven Hello World Example
- Configuring the HTTP Port on Quarkus Applications
- Quarkus - Interview questions and answers
Following technologies stack being used:
- JDK 11
- IntelliJ IDEA
- Quarkus 1.3.0
- Maven
1.Maven/Dependency Management [pom.xml]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>QuarkusHelloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<properties><compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>2.2.3.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>2.2.3.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement><dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
The Quarkus core Technologies:
- Quarkus uses RESTEasy for the JAX-RS endpoint.
- Quarkus uses Vert.x and Netty at its core, providing reactive and non-blocking HTTP layer.
- Quarkus uses JBoss Log Manager as the default logging framework.
- Quartus utilizes a modified version of Undertow that runs on top of Vert.x
- Quarkus uses SmallRye Config, implementation of Eclipse MicroProfile Config, for configuration data.
- Quarkus uses JUnit 5 for testing.
- Quarkus uses rest-assured to test HTTP endpoints.
2. Quarkus JAX-RX endpoint
package com.knf.endpoint;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/api/hello")
public class EndPoint {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getUsers() {
return "Hello World";
}
}
3 . Testing
Build application jar file: mvn clean package
Start application: java -jar quarkus-run.jar
Open the browser and hit the endpoint localhost:8080/api/hello
Download the source code: