Skip to main content

Activate a Spring Boot Profile for a Component

๐ŸŽฏcontext

You have defined different Spring Boot profiles for your Java Domain Service service and want to activate one of them when deploying the service through an application composition project in order to apply a specific bunch of configurations.

Descriptionโ€‹

This How-To will teach you how you can activate different Spring Boot profiles for your Java Domain Service service built with the Workbench.

Preconditionsโ€‹

  • You have developed and released a Java Domain Service service successfully.
  • Your service contains one or many Spring Boot profile files.
  • You have created an application composition project through which you want to deploy the service.

Stepsโ€‹

Option 1โ€‹

  1. Add the component to your Application Composition project.

  2. Open the component configuration.

  3. Define a custom configuration.

    configmap:  
    extraConfiguration: |
    spring.profiles.active=prod,profile1,profile2

Option 2โ€‹

  1. Open your service project and define a new environment variable "SPRING_PROFILES_ACTIVE" as key value pair and set value to "default". Please have a look in the Product documentation

  2. Create a new release of the service.

  3. Update the version of the service in the application.

  4. Open component configuration.

  5. Define a custom configuration.

    env:
    variables:
    keyValue:
    variableName: SPRING_PROFILES_ACTIVE
    value: "profile1"

  1. Commit Application to deploy the service with the spring profile.
๐Ÿ”ฅdanger

Please be aware that activating Spring Boot profiles may also have an effect on your spring application configuration by way of which configuration files are consulted on boot-up, for more details please read Spring boot documentation.

๐Ÿ’กtip

Within another Application Composition Project, another Spring Boot Profile can be activated.

๐ŸŒŸCongratulations!

You have successfully activated the profile on a component.