I would like to override the properties I have configured in my configuration file in my Quarkus application.
How can I accomplish that?
To override your Spring Boot application properties when it's running on Kubernetes, just set environment variables on the container. To set an environment variable on a container, first, initialise a ConfigMap containing the environment variables that you want to override.
Quarkus uses MicroProfile Config annotations to inject the configuration properties in the application. You can use @Inject @ConfigProperty or just @ConfigProperty .
The overridability of the former depends on the configuration in question. For example, the http properties (like quarkus.http.port) are overridable. The later are always overridable at runtime. When running a Quarkus application in JVM mode you can, for example, do:
This is a user-defined configuration property. This is a configuration property consumed by the quarkus-vertx-http extension. It works in the exact same way as Quarkus Application configuration file application.properties. Recommendation is to use Quarkus application.properties . 1.6.
Properties in Quarkus are generally configured in src/main/resources/application.properties. This is true both for properties that configure the behavior of Quarkus (like the http port it listens to or the database URL to connect to for example) and properties that are specific to your application (for example a greeting.message property).
By default, Quarkus has three profiles: dev– Activated when in development mode (i.e. quarkus:dev) test– Activated when running tests prod– The default profile when not running in development or test mode 2.2 The Quarkus supports the following syntax to change the property value based on profiles. %{profile}.config.key=value For example:
Properties in Quarkus are generally configured in src/main/resources/application.properties
.
This is true both for properties that configure the behavior of Quarkus (like the http port it listens to or the database URL to connect to for example) and properties that are specific to your application (for example a greeting.message
property).
The overridability of the former depends on the configuration in question. For example, the http properties (like quarkus.http.port
) are overridable.
The later are always overridable at runtime.
When running a Quarkus application in JVM mode you can, for example, do:
java -Dgreeting.message=hi -jar example-runner.java
Similarly, when running a Quarkus application that has been converted to a native binary using the GraalVM (specifically the SubstrateVM system), you could do:
./example-runner -Dgreeting.message=hi
More information can be found on the "Quarkus - Configuring Your Application" official guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With