이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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.

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat