I have three YAML files in my project application-prod.yaml application-dev.yaml application.yaml

spring.profiles.active not possible to set in profile-specific YAML after upgrade

not possible to set this spring.profiles.active in the application.YAML dynamically on the basis of which profiles we want to activate, as we are using mvn -Pprod or mvn -Pdev Environment file in spring core using get active profiles from path "spring.profiles.active" so it returns empty active profiles collection so getting this info for each "mvn -Pprod or mvn -Pdev " No active profile set, falling back to default profiles: Earlier it was working before 2.4.x upgrade

Comment From: philwebb

Spring Boot 2.4 changed where profile files can be activated. Please take a look at this guide to see if it helps.

From the description, It's not totally clear how your previous setup worked. Perhaps you can provide a small sample application that shows exactly what you're trying to do?

Comment From: vkatoch2000

As per 2.4, its profile-specific file first which is application-dev or application-prod depends upon which profile we have input in maven command, after processing it, it picks application.yml where we have used profile groups

spring:
    profiles:
        group:
            prod:
                - X
                - Y
            dev:
                - X1
                - Y

what problems is that how can I set spring. profiles. active = dev or prod depends on which profiles have input in the command line, can we add some conditions to set the value to dev or prod or do we need to set this in system environment variables ??

Spring core using this spring. profiles. active key to set active environment values in code. org.springframework.core.env.AbstractEnviornment public static final String ACTIVE_PROFILES_PROPERTY_NAME = "spring.profiles.active";

Comment From: wilkinsona

@vkatoch2000 Unfortunately it’s still rather hard for us to tell exactly what you are trying to do. If you would like us to spend some more time investigating then, as Phil requested above, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: vkatoch2000

I have been able to fix it after using mvn -Dspring-boot.run.profiles= dev or prod locally to ru in production we can use java -Dspring.profiles.active=profile-to-be-activated -jar war or jar executable closing this issue