liveBook · Manning

Code reloading

As explained in Quarkus in Action

A development-time process that applies code or configuration changes by reloading an application without a full manual restart.

Code reloading shortens the edit–check loop in a Quarkus application. In Dev mode, save a change and send an HTTP request, such as by refreshing a browser page. Quarkus recompiles and reloads the application in the background, then serves the request using the changed version. There is no need to manually package, restart, or launch a new JVM for each edit. section 2.3 section 3.1

To try the loop:

  • Start Dev mode with `./mvnw quarkus:dev`, `./gradlew --console=plain quarkusDev`, or `quarkus dev`, according to your tooling. section 2.3
  • Change a Java REST resource, save it, and refresh its browser page. You can also press `s` in the Dev mode terminal to trigger a reload without sending a request. section 3.1.1
  • Change an HTML resource or `application.properties` in the same way. Changes to `pom.xml` or `build.gradle`, including a new dependency, can also trigger a reload. section 3.1.2

A detected change does not reload immediately: Quarkus waits for a request or a manual trigger, holds the request while reloading, and then responds. Reloads normally take a few hundred milliseconds, though work such as downloading a new dependency can take longer. The process reuses the JVM through a class-loader architecture; its internals are beyond this practical workflow. section 3.1.2

Change a greeting, then break it

Change the string returned by a REST greeting method and refresh to see the new response. Dev mode logs the stop and reload time. If you instead remove the return statement’s semicolon, the next request produces an HTTP 500 error page with compilation details; Dev mode remains running so you can correct the code and try again. section 3.1.1 section 3.7

A full reload discards application state: classes are loaded again in a new class loader, and the old objects are released. For some minor changes, instrumentation-based reload can preserve affected objects by replacing bytecode instead; enable it with `quarkus.live-reload.instrumentation=true` in `application.properties` or press `i` in the terminal or Dev UI. Extensions that hold connections or files may need shutdown hooks to clean them up during hot reload. This is a development workflow, not a substitute for packaging and running the production application. section 3.1.2 section 12.1.5 section 2.3

How Quarkus in Action covers it

How deep it goes
Explains triggers, request handling, state loss, and optional instrumentation, but defers class-loader architecture details.
Examples
Uses a changed REST greeting, a missing semicolon, and Dev mode console logs to demonstrate successful and failed reloads.
What it assumes
Assumes a generated Quarkus project and familiarity with editing a Java REST resource; provides commands for starting Dev mode.
What you can do after
Operate/configure it with Quarkus Dev mode commands, request-triggered reloads, and the optional instrumentation setting.
How it connects
Connects Dev mode with HTTP requests, configuration files, class loaders, continuous testing, and extension shutdown hooks.

Also explained in

Compare how 4 books explain code reloading →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.