Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions docs/src/main/asciidoc/application-configuration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private String suffix;
private Optional<String> name;
----

The first property is _mandatory_. If you do not provide a value, the build fails.
If you do not provide a value for the first property, it will have a `null` value.
The second property injects the given default value if the configuration file does not provide a value.
The third property is optional. The injected `Optional` is empty as the configuration file does not provide a value.

Expand All @@ -92,8 +92,8 @@ public String hello() {

== Create the configuration

By default, Quarkus reads `META-INF/microprofile-config.properties`.
Edit the `src/main/resources/META-INF/microprofile-config.properties` with the following content:
By default, Quarkus reads `application.properties`.
Edit the `src/main/resources/application.properties` with the following content:

[source]
----
Expand Down Expand Up @@ -153,4 +153,38 @@ Changing the configuration file is immediately reflected.
You can add the `greeting.suffix`, remove the other properties, change the values, etc.

As usual, the application can be packaged using `mvn clean package` and executed using the `-runner.jar` file.
You can also generate the native executable with `mvn clean package -Pnative`.
You can also generate the native executable with `mvn clean package -Pnative`.

== Overriding properties at runtime

{project-name} does much of its configuration and bootstrap at build time.
Most properties will then be read and set during the build time step.
To change them, make sure to repackage your application.

[source,bash]
--
mvn clean package
--

Extensions do define _some_ properties as overridable at runtime.
A canonical example is the database URL, username and password which is only known specifically in your target environment.
This is a tradeoff as the more runtime properties are available, the less build time prework Quarkus can do. The list of runtime properties is therefore lean.

You can override these runtime properties with the following mechanisms (in decreasing priority):

1. using system properties:
* for a runner jar: `java -Dquarkus.datasource.password=youshallnotpass -jar target/myapp-runner.jar`
* for a native image: `./target/myapp-runner -Dquarkus.datasource.password=youshallnotpass`
2. using environment variables:
* for a runner jar: `export QUARKUS_DATASOURCE_PASSWORD=youshallnotpass ; java -jar target/myapp-runner.jar`
* for a native image: `export QUARKUS_DATASOURCE_PASSWORD=youshallnotpass ; ./target/myapp-runner`

NOTE: Environment variables names are following the conversion rules of link:https://github.com/eclipse/microprofile-config/blob/master/spec/src/main/asciidoc/configsources.asciidoc#default-configsources[Eclipse MicroProfile]

== More info on how to configure

{project-name} relies on Eclipse MicroProfile and inherit its features.

There are converters that convert your property file content from `String` to typed Java types. See the list link:https://github.com/eclipse/microprofile-config/blob/master/spec/src/main/asciidoc/converters.asciidoc[in the specification].

// TODO: make Ken review this section and discuss SmallRye expansion.