Spring-Boot Version: 2.4.0

When migrate from spring.profiles.include to spring.profiles.group, Spring-Boot no longer load sub yml configs from the classpath.

application.yml

spring:
  profiles:
    group:
      - base-db
      - base-quartz
      - base-app

main resource: SpringBoot How to load sub yml config file use spring.profiles.group property?

application-test.yml

spring:
  profiles:
    group:
      - test-db
      - test-quartz
      - test-app

test resource: SpringBoot How to load sub yml config file use spring.profiles.group property?

log shows Spring-Boot only load application.yml and application-test.yml, but no base-db, base-quartz, base-app,test-db, test-quartz, test-app

2020-12-02 13:22:07.463 TRACE  [main] org.springframework.boot.context.config.ConfigDataEnvironment Adding imported property source 'Config resource 'classpath:/application-test.yml' via location 'optional:classpath:/''
2020-12-02 13:22:07.463 TRACE  [main] org.springframework.boot.context.config.ConfigDataEnvironment Adding imported property source 'Config resource 'classpath:/application.yml' via location 'optional:classpath:/''

If run with --spring.profiles.active=test, Spring-Boot should also load base-db, base-quartz, base-app,test-db, test-quartz, test-app too, am i right?

Comment From: philwebb

You need to include the source profile as part of the group property (see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-profiles-groups). For example:

spring:
  profiles:
    group:
      test:
      - test-db
      - test-quartz
      - test-app

For the base- profiles you probably want the following since they're always active:

spring:
  profiles:
    include:
    - base-db
    - base-quartz
    - base-app

Comment From: blling

Thanks,how does test- inherit base-? For example, i need test-app inherit base-app to change a property value in the base-app,then what is the the config looks like?

Comment From: philwebb

I think the example I included should so that. If not, please ask the question on stackoverflow.com with a small sample app. If you post a link to the question here, I'll try to answer it on stackoverflow. We prefer to keep the issue tracker just for bugs.

Comment From: blling

@philwebb Thinks! Finally, application-test.yml worked use the config as follows:

spring:
  profiles:
    group:
      test:
        - base-app
        - base-db
        - base-quartz
      base-app: test-app
      base-db: test-db
      base-quartz: test-quartz

The inheritance relationship on the configuration looks a bit strange, but it works.

BTW. The follow configuration should not work:

spring:
  profiles:
    group:
      test:
        - test-app
        - test-db
        - test-quartz
      test-app: base-app
      test-db: base-db
      test-quartz: base-quartz

Because, by this way, the base-* properties will cover the test-*, but i want test-* cover base-* :-( . I do not know if this is a expected design, but it looks really strange.

Comment From: blling

Ref: #24172

Comment From: vignesh-ragavan

How to run the application using group name? -Dspring.profile.active=groupname @philwebb

Comment From: wilkinsona

@vignesh-ragavan As Phil said above, please ask questions on Stack Overflow.