liveBook · Manning

Application properties

As explained in Quarkus in Action

application.properties is a Java application configuration file containing key-value property settings.

`application.properties` is the default configuration file for a Quarkus application. It normally lives at `src/main/resources/application.properties` in Maven or Gradle projects. One file can hold settings for Quarkus extensions alongside values defined by the application; added extensions contribute their own available properties. Other configuration locations are possible. section 2.2.2 section 3.2

Use an application-specific property to replace a hard-coded value. For example, add `greeting=Hello configuration`, then inject `greeting` into a REST resource with `@ConfigProperty(name = "greeting")`. The `/hello` response then uses the configured value. Quarkus integrates with the MicroProfile Config API for application access to properties. Reserve the `quarkus.` prefix for built-in settings; use another prefix or name for your own. section 3.2.1 section 3.2

Listing 3.2 Injecting a configured greeting message
import org.eclipse.microprofile.config.inject.ConfigProperty;

...

public class GreetingResource {

    @ConfigProperty(name = "greeting")
    String greeting;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return greeting;
    }

...

The resource shows the configured greeting injected into a field and returned by its HTTP endpoint. section 3.2.1

Choose how and when a setting should take effect:

  • At startup, JVM system properties override environment variables, which override `application.properties`. For `my.greeting`, the environment-variable form is `MY_GREETING`; a deployment can change the value without editing the file packaged in the artifact. section 3.2.3
  • Use `%prod.` before a property for production-only settings. For example, production OIDC properties can point services to a manually managed Keycloak instance without changing their Dev mode setup. section 6.4.2
  • Distinguish runtime settings from build-time settings. `quarkus.kubernetes.*` properties customize generated manifests when the image and manifests are built; changing them at application startup will not alter those manifests. section 11.3.2

Configure a service connection

Replace a REST client's hard-coded base URI with `@RegisterRestClient(configKey = "reservations")`, then set `quarkus.rest-client.reservations.url=http://localhost:8081` in `application.properties`. The client location can now be adjusted through configuration rather than the interface annotation. A localhost value is useful while running services locally but needs reconsideration for cloud deployment. section 11.1.1

In Dev mode, the Dev UI Config Editor lists available extension and application properties, including defaults. Edits persist to `application.properties`, but entries there do not become JVM system properties or environment variables: read application values through the configuration API. For a YAML file instead, add the `quarkus-config-yaml` extension. Extension guides list their available configuration properties. section 3.3.1 section 3.2

How Quarkus in Action covers it

How deep it goes
Works through injection, override priority, profiles, and build-time manifest settings; defers exhaustive extension options and exact environment-variable mapping rules to documentation.
Examples
Shows an injected greeting, system-property and environment-variable overrides, production Keycloak settings, and a configured REST client URL.
What it assumes
Starts with an initially empty generated configuration file, then uses a Java REST resource and Dev mode to demonstrate changes.
What you can do after
Apply it via Quarkus configuration and MicroProfile Config injection to replace hard-coded values and adapt service settings across environments.
How it connects
Connects MicroProfile Config, REST clients, OIDC, Dev UI, and Kubernetes manifest generation through application and extension properties.

Also explained in

Compare how 2 books explain application properties →

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.