Este conteúdo não está disponível no idioma selecionado.

Chapter 8. Using configuration profiles


You can use different configuration profiles depending on your environment. Configuration profiles enable you to have multiple configurations in the same file and select between them using a profile name. Red Hat build of Quarkus has three configuration profiles. In addition, you can create your own custom profiles.

Quarkus default profiles:

  • dev: Activated in development mode
  • test: Activated when running tests
  • prod: The default profile when not running in development or test mode

Prerequisites

  • You have a Quarkus Maven project.

Procedure

  1. Open your Java resource file and add the following import statement:

    import io.quarkus.runtime.configuration.ProfileManager;
    Copy to Clipboard Toggle word wrap
  2. To display the current configuration profile, add a log invoking the ProfileManager.getActiveProfile() method:

    LOGGER.infof("The application is starting with profile `%s`", ProfileManager.getActiveProfile());
    Copy to Clipboard Toggle word wrap
    Note

    It is not possible to access the current profile using the @ConfigProperty("quarkus.profile") method.

8.1. Setting a custom configuration profile

You can create as many configuration profiles as you want. You can have multiple configurations in the same file and you can select between them using a profile name.

Procedure

  1. To set a custom profile, create a configuration property with the profile name in the application.properties file, where <key> is the name of the property, <value> is the property value, and <profile> is the name of a profile:

     %<profile>.<key>=<value>
    Copy to Clipboard Toggle word wrap

    In the following example configuration, the value of quarkus.http.port is 9090 by default, and becomes 8181 when the dev profile is activated:

    quarkus.http.port=9090
    %dev.quarkus.http.port=8181
    Copy to Clipboard Toggle word wrap
  2. Use one of the following methods to enable a profile:

    • Set the quarkus.profile system property.

      • To enable a profile using the quarkus.profile system property, enter the following command:

        mvn -Dquarkus.profile=<value> quarkus:dev
        Copy to Clipboard Toggle word wrap
    • Set the QUARKUS_PROFILE environment variable.

      • To enable profile using an environment variable, enter the following command:

        export QUARKUS_PROFILE=<profile>
        Copy to Clipboard Toggle word wrap
        Note

        The system property value takes precedence over the environment variable value.

  3. To repackage the application and change the profile, enter the following command:

    ./mvnw package -Dquarkus.profile=<profile>
     java -jar target/myapp-runner.jar
    Copy to Clipboard Toggle word wrap

    The following example shows a command that activates the prod-aws profile:

    ./mvnw package -Dquarkus.profile=prod-aws
     java -jar target/myapp-runner.jar
    Copy to Clipboard Toggle word wrap
Note

The default Quarkus application runtime profile is set to the profile used to build the application. Red Hat build of Quarkus automatically selects a profile depending on your environment mode. For example, when your application is running as a JAR, Quarkus is in prod mode.

Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat