Quarkus with kotlin getting started example. If you are new to the quarkus then please watch the below video to get started with Quarkus.
Tech Stack:
- Kotlin
- VSCode
- Quarkus
- GRadle
- REST API
Create Project:
Create a project using the launch Quarkus Initializr using https://code.quarkus.io/ or you can use the VSCode editor.
Check the above screenshot, we have specified the following details:
- Build Tool: Gradle with Kotlin
- Group: org.techwasti.demo
- Artifact: kotlin-quarkus-hello
- Search & Pick extensions: RESTEasy JSON-B
Generate a Quarkus project and downloads it. then, Unzip the downloaded zip file and import it into your favorite IDE.
See the Project Structure,
Quarkus core Technologies :
- Quarkus uses RESTEasy for the JAX-RS endpoint.
- Quarkus uses Vert.x and Netty at its core, providing a 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.
For testing:
- Quarkus uses JUnit 5 for testing.
- Quarkus uses rest-assured to test HTTP endpoints.
build.gradle file
plugins {
id 'java'
id 'io.quarkus'
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-resteasy-reactive-jsonb'
implementation 'io.quarkus:quarkus-arc'
implementation 'io.quarkus:quarkus-resteasy-reactive'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}
group 'org.techwasti.demo'
version '1.0.0-SNAPSHOT'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-parameters'
}
compileTestJava {
options.encoding = 'UTF-8'
}
Let us see the hello world controller coding.
package org.techwasti.demo;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello from RESTEasy Reactive";
}
}
In this code snippet, we have a GET endpoint that is returning the string. Let us run the command to build the project
gradle build
To run the application then use the below command.
./gradlew --console=plain quarkusDev
And hit URL
$ curl -w "\n" http://localhost:8080/hello
SourceCode:
Find the complete source code here.
https://github.com/knowledgefactory4u/Quarkus/tree/main/kotlin-quarku-helloworld
Conclusion:
This article demonstrates you quarkus kotlin helloworld application.
More such articles:
https://www.youtube.com/channel/UCiTaHm1AYqMS4F4L9zyO7qA
==========================**=========================
If this article adds any value for you then please clap and comment.
Letβs connect on Stackoverflow, LinkedIn, & Twitter.
Did you find this article valuable?
Support techwasti by becoming a sponsor. Any amount is appreciated!