Language: Java
Web
Quarkus was created to optimize Java for containerized environments and serverless deployments. It leverages compile-time boot, GraalVM native image support, and reactive programming to provide a high-performance and developer-friendly framework for modern applications.
Quarkus is a Kubernetes-native Java framework designed for building cloud-native, reactive, and serverless applications with fast startup times and low memory footprint.
Add io.quarkus:quarkus-bom and required extensions in pom.xmlAdd implementation platform('io.quarkus:quarkus-bom:3.3.0.Final') and dependencies like implementation 'io.quarkus:quarkus-resteasy'Quarkus allows building REST APIs, reactive services, microservices, and serverless applications. It provides seamless integration with Hibernate, JPA, messaging systems, and cloud-native features, with support for reactive and imperative programming models.
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
@Path("/hello")
public class HelloResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello Quarkus!";
}
}Defines a basic REST endpoint that responds with 'Hello Quarkus!' on GET requests to `/hello`.
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.annotations.QuarkusMain;
@QuarkusMain
public class MainApp {
public static void main(String... args) {
Quarkus.run(args);
}
}Bootstraps a Quarkus application using the main method.
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
@Singleton
public class MyService {
public String getMessage() { return "Service Message"; }
}
@Path("/service")
public class ServiceResource {
@Inject
MyService myService;
@GET
public String message() {
return myService.getMessage();
}
}Demonstrates injecting a service into a REST resource using Quarkus and Jakarta DI.
import io.smallrye.mutiny.Uni;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
@Path("/reactive")
public class ReactiveResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public Uni<String> hello() {
return Uni.createFrom().item("Hello Reactive Quarkus!");
}
}Defines a reactive REST endpoint using Mutiny for asynchronous, non-blocking responses.
import io.quarkus.hibernate.orm.panache.PanacheEntity;
import jakarta.persistence.Entity;
@Entity
public class Person extends PanacheEntity {
public String name;
public int age;
}Defines a simple entity with Quarkus Panache for ORM support with minimal boilerplate.
import io.quarkus.arc.config.ConfigProperties;
@ConfigProperties(prefix="app")
public class AppConfig {
public String name;
}Maps configuration properties from application.properties or application.yml into a Java class.
Use reactive programming with Mutiny for high-performance non-blocking services.
Leverage Panache for simpler and efficient ORM operations.
Externalize configuration and use type-safe config classes.
Organize code with REST resources, services, and entities for modularity.
Integrate Quarkus with CI/CD pipelines for containerized deployments.