Skip to content
Tutorials Center
My learning

Topics

Lesson 100 of 119 ยท Architecture and Deployment

Quarkus and Micronaut Compared

Compare Quarkus and Micronaut with Spring Boot - build-time dependency injection, startup and memory, native images, code samples, dev experience and how to choose.

Spring Boot is the default choice for Java back ends, and after reading the lessons so far you can build real services with it. But it is not the only mature option. Two frameworks, Quarkus and Micronaut, were designed for containers, serverless functions and native images from the first line of code. They look familiar if you know Spring (annotations, dependency injection, REST controllers, configuration files), yet they work differently inside, and that difference is the reason they exist.

This lesson is a guided comparison. You will learn the one big idea they share (move work from startup to build time), see the same small REST endpoint in all three frameworks, and get a checklist for choosing. The frameworks themselves aren't available in this course's code runner, so their code is shown read-only; the runnable examples demonstrate the core mechanism in plain Java. Read GraalVM native images first if you haven't, because much of the motivation comes from there.

The shared idea: do the work at build time

When a classic Spring application starts, it discovers its own structure while running. It scans the classpath for annotated classes, reads annotations through reflection, evaluates conditions, creates proxies at run time, and wires the beans together. That flexibility costs time and memory on every start, and it is awkward for native images, which dislike reflection.

Quarkus and Micronaut do that discovery when you build:

flowchart LR
  subgraph Classic["Classic runtime approach"]
    direction TB
    c1["Build: compile only"] --> c2["Start: scan classpath,<br/>read annotations by reflection,<br/>create proxies, wire beans"]
  end
  subgraph BuildTime["Build-time approach"]
    direction TB
    b1["Build: compile +<br/>analyze annotations,<br/>generate wiring code"] --> b2["Start: run the<br/>already-generated code"]
  end

Both approaches produce the same object graph. The build-time approach pays for the analysis once, on the build server, instead of on every start of every instance.

The two frameworks reach this goal differently:

  • Micronaut uses Java annotation processors. While javac compiles your code, a processor reads annotations such as @Singleton and @Controller and generates extra classes (bean definitions, injection code, proxies). At run time Micronaut calls the generated code directly. No reflection and no classpath scanning are needed, even on the JVM.
  • Quarkus uses a build step called augmentation. After compilation, Quarkus extensions analyze your bytecode and the libraries' bytecode, record the result, and generate optimized bytecode that is loaded at run time. Quarkus keeps familiar standards at the front: CDI (Jakarta Contexts and Dependency Injection, implemented by its ArC container), Jakarta REST for endpoints and MicroProfile specifications for configuration, health and fault tolerance.

Both ship GraalVM native-image metadata with their modules, so the native build is a normal command rather than an adventure.

Seeing the difference in plain Java

The first example builds the same three-object graph twice. The "runtime" container finds dependencies by reflection and counts how often it asks the reflection API for something. The "build-time" version is what a code generator would have produced: plain constructor calls.

Java Runtime wiring versus generated wiring

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Three beans took nine reflective calls. A real application has thousands of beans plus conditions, property binding and proxy creation, which is where seconds go. The generated version does the same job with ordinary, inlinable, analyzable Java.

Here is what the build-time step actually produces, simulated: a tiny generator that reads bean descriptors (what an annotation processor reads from your classes) and writes factory source code in dependency order.

Java A miniature code generator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

That last line is a real benefit. Because the wiring is known at build time, an injection point with no matching bean fails the build, not the production start. Micronaut reports it during javac; Quarkus reports it during augmentation.

The same endpoint in three frameworks

A "list books" endpoint with an injected service. First Spring Boot, which you know:

Java
@RestController
@RequestMapping("/books")
class BookController {
    private final BookService books;

    BookController(BookService books) {
        this.books = books;
    }

    @GetMapping
    List<Book> all() {
        return books.findAll();
    }
}

Quarkus, using Jakarta REST and CDI:

Java
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;

@Path("/books")
@Produces(MediaType.APPLICATION_JSON)
public class BookResource {

    @Inject
    BookService books;

    @GET
    public List<Book> all() {
        return books.findAll();
    }
}

Micronaut, with its own lightweight annotations and constructor injection:

Java
import io.micronaut.http.annotation.*;

@Controller("/books")
class BookController {
    private final BookService books;

    BookController(BookService books) {
        this.books = books;
    }

    @Get
    List<Book> all() {
        return books.findAll();
    }
}

The shapes are nearly identical, so your Spring knowledge transfers. The differences are in the ecosystem around the code:

Topic Spring Boot Quarkus Micronaut
DI model Spring beans, runtime scanning (plus AOT for native) CDI (ArC), build-time Own DI, annotation processors
Web API Spring MVC / WebFlux Jakarta REST (Quarkus REST), reactive by design @Controller, Netty-based server
Persistence Spring Data JPA Hibernate ORM with Panache, Hibernate Reactive Micronaut Data (compile-time repositories), JPA or JDBC
Config file application.yml / .properties application.properties (YAML supported) application.yml / .properties
Testing @SpringBootTest @QuarkusTest @MicronautTest
Project start start.spring.io code.quarkus.io, quarkus create app micronaut.io/launch, mn create-app
Native image Supported via AOT (since Boot 3) First-class, mature First-class, mature
Ecosystem size Largest by far Large, Red Hat backed Smaller, Object Computing / Oracle ecosystem

What each framework does well

Quarkus

  • Dev mode: ./mvnw quarkus:dev (or quarkus dev) starts the app with live reload. Edit a class, refresh the browser, and the change is compiled and applied in about a second, without restarting the JVM. It also has a built-in Dev UI.
  • Dev Services: when you add an extension such as PostgreSQL or Kafka and configure nothing, Quarkus starts a matching container for you in dev and test mode (using Docker or Podman) and wires the connection. Compare with the manual Compose file in Docker for Java Developers.
  • Panache simplifies persistence: public class Book extends PanacheEntity { public String title; } gives you Book.listAll() and book.persist().
  • Extensions are curated: each one is built and tested together with the core, instead of leaving you to align dozens of library versions.

Micronaut

  • Micronaut Data generates the repository implementation at compile time from an interface, with queries checked while compiling: interface BookRepository extends CrudRepository<Book, Long> { List<Book> findByAuthorOrderByTitle(String author); }.
  • Declarative HTTP clients: annotate an interface with @Client("/api") and call it like a normal object, similar to the OpenFeign style in Load Balancing and OpenFeign.
  • Small footprint without native: even on the plain JVM, the absence of reflection-based scanning keeps start-up time and memory low, and the framework is built for functions-as-a-service (AWS Lambda, Azure Functions, Google Cloud Functions) and microservices.
  • Service discovery, distributed configuration and tracing are built into the framework core, where Spring uses Spring Cloud.

Spring Boot

  • The largest ecosystem: Spring Data, Spring Security, Spring Batch, Spring Cloud, Spring AI, and the most tutorials, libraries, answers and hiring pool.
  • Since Spring Boot 3, AOT processing and native images close much of the technical gap, as the previous lesson showed.
  • Virtual threads (the concurrency lessons in Java) work with a single property, so the classic blocking style scales well.

Typical numbers, honestly

Vendor benchmark tables circulate widely and change with every release, so treat any specific number with suspicion. The pattern is stable, though: a minimal REST service starts in a few seconds on the JVM with Spring Boot, roughly a second or less with Quarkus or Micronaut on the JVM, and in tens of milliseconds as a native image with any of them. Memory follows the same ordering. For a realistic application with a database, security and messaging, the differences shrink, because most of the time goes into things the framework cannot avoid (opening connections, running migrations, warming caches).

Measure your own application before you decide. Startup time and idle memory of a real service, with its real dependencies, in the container size you plan to pay for, is the only comparison that matters.

Choosing

Choose Spring Boot when:

  • your team already knows it, or you depend on parts of its ecosystem (Spring Security, Spring Data, Batch, Integration, Cloud);
  • you are building a long-running service where startup time barely matters;
  • you want the widest choice of libraries, hosting guides and developers.

Consider Quarkus when:

  • you target Kubernetes or serverless and care about density (many small instances) and fast scale-up;
  • you like Jakarta EE / MicroProfile standards, or come from Java EE and WildFly or Payara;
  • the developer experience of dev mode and Dev Services appeals to you.

Consider Micronaut when:

  • you want compile-time guarantees and no reflection, even on the JVM;
  • you are writing serverless functions or small microservices where cold start matters;
  • you value built-in cloud features (discovery, config, clients) without an extra project.

Whatever you pick, the lessons in this course carry over: JDBC, SQL, JSON, testing with JUnit, REST design, security principles, messaging, observability and containers are the same concepts under different annotations. Many teams run all three side by side.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main idea shared by Quarkus and Micronaut?

    Both analyze annotations during the build (Micronaut with annotation processors, Quarkus with augmentation) and run generated code at start-up, which helps start-up time, memory and native images.
  2. 2. Which standards does Quarkus use as the front of its programming model?

    Quarkus endpoints use Jakarta REST (@Path, @GET) and injection uses CDI (@Inject), with MicroProfile for config, health and fault tolerance.
  3. 3. A required bean is missing in a Micronaut application. When do you usually find out?

    Because injection points are resolved while compiling, unsatisfied dependencies can be reported as build errors.
  4. 4. What does Quarkus Dev Services do in development and test mode?

    With a supporting extension and no explicit connection settings, Quarkus launches a matching container (via Docker or Podman) and wires it up.
  5. 5. Your team of Spring experts builds a long-running line-of-business service that relies on Spring Security and Spring Batch. What is the most sensible framework?

    Framework choice should follow team skills, ecosystem needs and measured requirements. Native images and fast starts matter most for serverless and high-density workloads.

Summary

  • Quarkus and Micronaut shift dependency-injection analysis, proxy creation and configuration processing from application start-up to build time, giving faster starts, lower memory and smooth native images.
  • Micronaut generates code with annotation processors and uses no reflection; Quarkus uses augmentation and builds on CDI, Jakarta REST and MicroProfile.
  • The code looks like Spring: annotated controllers, constructor or field injection, a properties/YAML file, a test annotation per framework.
  • Quarkus is known for dev mode, Dev Services and Panache; Micronaut for compile-time repositories, declarative clients and serverless focus; Spring Boot for the largest ecosystem and community.
  • Missing or circular beans can be build errors rather than production start-up failures.
  • Choose by team skills, ecosystem needs and measured start-up and memory in your own environment, not by headline benchmarks.

Next: JMS and Message Queues returns to messaging with the standard Java API for brokers.