Hardcoded values in your code is a no go, so let’s see how to add configuration to your application. Quarkus relies on the MicroProfile Config specification and the main configuration file is

Using a config property in your code

Let’s change our GreetingResource class to use a configuration property. Change its content to:

package com.redhat.developers;

import org.eclipse.microprofile.config.inject.ConfigProperty;


public class GreetingResource {

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

    public String hello() {
        return greeting;

If you refresh your browser pointing to http://localhost:8080/hello, you should see an error with a stacktrace like this:

jakarta.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: greeting
	at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties61.deploy_0(ConfigBuildStep$validateConfigProperties61.zig:120)
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties61.deploy(ConfigBuildStep$validateConfigProperties61.zig:36)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:166)
	at io.quarkus.runtime.Application.start(
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.base/java.lang.reflect.Method.invoke(
	at io.quarkus.runner.bootstrap.StartupActionImpl$
	at java.base/

Which is expected, since we didn’t provide the greeting property neither at the file nor with some runtime configuration.

Adding a config property to

Since we requested a greeting property in our code, let’s provide a value to it in our file available in src/main/resources:

# Configuration file
# key = value
greeting=Hello y'all!

Refresh your browser pointing to http://localhost:8080/hello. You should see the Hello y’all! string.

You can also use curl to check the same result:

curl localhost:8080/hello
Hello y'all!

Update your integration test

Since we changed the output of our /hello endpoint, our integration test doesn’t pass anymore.

Let’s update GreetingResourceTest to reflect our recent changes:

package com.redhat.developers;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static;

public class GreetingResourceTest {

    public void testHelloEndpoint() {
             .body(is("Hello y'all!"));

If you’re still running in live testing mode you will already see that the tests pass again and you can ignore the rest of this page and move on to the next step.

Stop your current Live Coding session of Quarkus in the terminal by sending a CTRL+C:

^C2020-05-11 08:33:41,865 INFO  [io.quarkus] (Quarkus Main Thread) tutorial-app stopped in 0.007s

Now run your tests to check if everything is ok:

  • Maven

  • Quarkus CLI

./mvnw clean test
quarkus test
[INFO] Results:
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.851 s
[INFO] Finished at: 2020-05-11T21:31:31-04:00
[INFO] ------------------------------------------------------------------------

BUILD SUCCESS! You can now go back to the amazing Live Coding mode of Quarkus:

  • Maven

  • Quarkus CLI

./mvnw quarkus:dev
quarkus dev