Website Backend Development with Java (Quarkus)
Quarkus is a Java framework rethought for cloud-native and Kubernetes. Its key difference from Spring Boot: Quarkus compiles the application into a native binary via GraalVM Native Image. Cold start time is 0.01–0.1 seconds versus 2–10 seconds for Spring Boot. Memory consumption is 20–60 MB versus 200–500 MB.
These aren't just benchmark numbers. In Kubernetes environments with autoscaling, fast startup means real horizontal scaling: a Pod comes up in seconds, not minutes. On Serverless, it's the difference between a working and non-working solution.
In JVM mode, Quarkus competes with Spring Boot. In native mode, it competes with Go.
Differences from Spring Boot
Quarkus uses familiar specifications: JAX-RS, CDI, JPA, MicroProfile. If you know Spring, the transition takes days. Key differences:
- Dependency Injection via CDI (
@ApplicationScoped,@RequestScoped), not Spring DI - REST via RESTEasy Reactive (JAX-RS), not Spring MVC
- ORM — Hibernate with Panache (Active Record or Repository pattern)
- Configuration via
application.propertiesor YAML, MicroProfile Config
Structure and REST
// Product entity with Panache Active Record
@Entity
@Table(name = "products")
public class Product extends PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@Column(nullable = false, length = 255)
public String name;
@Column(unique = true)
public String slug;
@Column(precision = 10, scale = 2)
public BigDecimal price;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "category_id")
public Category category;
public boolean isActive = true;
@Column(columnDefinition = "jsonb")
@Type(JsonType.class)
public Map<String, Object> attributes = new HashMap<>();
// Panache static methods
public static List<Product> findActive() {
return list("isActive", true);
}
public static Page<Product> findActiveByCategory(Long categoryId, int page, int size) {
return find("category.id = ?1 and isActive = true", categoryId)
.page(page, size);
}
}
Resource (Controller)
@Path("/api/v1/products")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApplicationScoped
public class ProductResource {
@Inject
ProductService productService;
@GET
@Authenticated
public Response list(
@QueryParam("page") @DefaultValue("0") int page,
@QueryParam("size") @DefaultValue("20") @Max(100) int size,
@QueryParam("category_id") Long categoryId) {
PanacheQuery<Product> query = categoryId != null
? Product.find("category.id = ?1 and isActive = true", categoryId)
: Product.find("isActive", true);
List<Product> products = query
.page(page, size)
.list();
long total = query.count();
return Response.ok(new PagedResponse<>(
products.stream().map(ProductDto::from).toList(),
page, size, total
)).build();
}
@POST
@RolesAllowed("admin")
@Transactional
public Response create(@Valid CreateProductRequest request) {
Product product = productService.create(request);
return Response.status(Response.Status.CREATED)
.entity(ProductDto.from(product))
.build();
}
@GET
@Path("/{id}")
public ProductDto get(@PathParam("id") Long id) {
return Product.findByIdOptional(id)
.map(ProductDto::from)
.orElseThrow(NotFoundException::new);
}
@DELETE
@Path("/{id}")
@RolesAllowed("admin")
@Transactional
public Response delete(@PathParam("id") Long id) {
boolean deleted = Product.deleteById(id);
return deleted ? Response.noContent().build() : Response.status(404).build();
}
}
Reactive endpoint
Quarkus with RESTEasy Reactive supports non-blocking operations natively:
@GET
@Path("/search")
public Uni<List<ProductDto>> search(@QueryParam("q") String query) {
return Product.<Product>find("name like ?1", "%" + query + "%")
.list()
.map(products -> products.stream().map(ProductDto::from).toList());
}
// Reactive DB work via Hibernate Reactive
@GET
@Path("/{id}/with-reviews")
public Uni<ProductWithReviews> getWithReviews(@PathParam("id") Long id) {
return Panache.withTransaction(() ->
Product.<Product>findById(id)
.flatMap(product -> Review.<Review>find("product.id", id).list()
.map(reviews -> new ProductWithReviews(product, reviews)))
);
}
Security via SmallRye JWT
# application.properties
mp.jwt.verify.publickey.location=META-INF/resources/publicKey.pem
mp.jwt.verify.issuer=https://myapp.com
quarkus.http.auth.permission.authenticated.paths=/api/v1/*
quarkus.http.auth.permission.authenticated.policy=authenticated
quarkus.http.auth.permission.public.paths=/api/v1/auth/*,/api/v1/products
quarkus.http.auth.permission.public.policy=permit
@Path("/api/v1/auth")
public class AuthResource {
@Inject
@Claim(standard = Claims.sub)
Optional<JsonString> subject;
@POST
@Path("/login")
@PermitAll
public Response login(@Valid LoginRequest request) {
User user = User.findByEmail(request.email())
.orElseThrow(() -> new UnauthorizedException("Invalid credentials"));
if (!BCrypt.verifyer().verify(request.password().toCharArray(), user.passwordHash).verified) {
throw new UnauthorizedException("Invalid credentials");
}
String token = Jwt.issuer("https://myapp.com")
.subject(user.id.toString())
.groups(Set.of(user.role))
.claim("email", user.email)
.expiresIn(Duration.ofHours(1))
.sign();
return Response.ok(new LoginResponse(token)).build();
}
}
Native build
# JVM mode (standard build)
./mvnw package -DskipTests
java -jar target/quarkus-app/quarkus-run.jar
# Native image — requires GraalVM or Docker
./mvnw package -Pnative -DskipTests
# Native in Docker without local GraalVM
./mvnw package -Pnative -Dquarkus.native.container-build=true
docker build -f src/main/docker/Dockerfile.native -t myapp .
# Image size: ~100MB (vs ~500MB JVM Spring Boot)
# Startup: ~50ms (vs 3-8s Spring Boot)
# Memory: ~30MB (vs ~200MB Spring Boot)
Kafka integration
// Producer
@ApplicationScoped
public class ProductEventProducer {
@Inject
@Channel("products-out")
Emitter<ProductEvent> emitter;
public void publishCreated(Product product) {
emitter.send(Message.of(new ProductEvent("created", product.id, product.name)));
}
}
// Consumer
@ApplicationScoped
public class InventoryConsumer {
@Incoming("inventory-updates")
public void onInventoryUpdate(InventoryUpdateEvent event) {
Product.update("stock = ?1 where id = ?2", event.stock(), event.productId());
}
}
Dev mode
Quarkus Dev Mode is one of the best hot-reload mechanisms in the Java ecosystem:
./mvnw quarkus:dev
# Any changes are applied without restart
# Dev UI available at localhost:8080/q/dev
# Built-in Dev Services: PostgreSQL, Redis, Kafka — start automatically in Docker
Development timeline
- Project setup + Dev Services + Flyway migrations — 3–5 days
- Entities (Panache) + Resources — 1–1.5 weeks
- Security + JWT — 3–5 days
- Reactive endpoints if needed — additional week
- Native build setup — 2–5 days (often requires reflection hints)
- Tests (QuarkusTest + RestAssured) — 1 week
Enterprise backend: 7–14 weeks. Quarkus pays off in Kubernetes environments, especially when you need fast autoscaling or Serverless deployment.







