Overview

I'm using spring boot application with cloud config. I tried to use profile groups but it doest not work that i expected. (I'm not sure it is a correct behavior or not)

  • SpringBoot : 2.4.5
  • Spring Cloud : 2020.0.2

Case

Application Config

bootstrap.yaml


spring:
  application:
    name: my-app

  cloud:
    config:
      uri: http://localhost:8080
      username: test
      password: test
      fail-fast: true
      label: dev

---
spring:
  cloud:
    config:
      label: dev
  config:
    activate:
      on-profile: default,test


---
# Stage profile
spring:
  cloud:
    config:
      label: stage
  config:
    activate:
      on-profile: stg

---
# Production profile

spring:
  cloud:
    config:
      label: master
  config:
    activate:
      on-profile: prod

Cloud Config

When I use spring.profiles.include, it works fine but group does not work for me. application.yaml

spring:
  application:
    name: my-app

  profiles:
#    include: "profileA,profileB,profileC".  => This works!
    group:  => This does not work!
      default:
        - "profileA"
        - "profileB"
        - "profileC"

application-default.yaml

my: value
// Result
The following profiles are active: default

// my expectation!
The following profiles are active: default,profileA,profileB,profileC

FYI, When I added spring.profiles.group in bootstrap.yaml in my application side, then it works. bootstrap.yaml


spring:
  application:
    name: my-app

  profiles:
    group:
      default:
        - "profileA"
        - "profileB"
        - "profileC"

But I would like to separate the code and configuration. How can i use spring.profiles.gruop in my cloud config?

Comment From: wilkinsona

Thanks for the report, but I cannot reproduce the behaviour that you have described.

As far as I can tell, neither spring.profiles.include nor spring.profiles.group works when used in configuration that's loaded via a configserver: import. Spring Cloud Config's ConfigServerConfigDataLocationResolver only participates in profile-specific resolution which I think is too late for spring.profiles.include or spring.profiles.group to have an effect.

In the description above, you have said that spring.profiles.include works but spring.profiles.group does not. Given that we're not seeing the same behaviour, I suspect I may not have understood your problem description. To remove any doubt, please provide a complete yet minimal example that reproduces the problem. It should include config server and config client applications and the necessary configuration to reproduce the problem. You can share them with us by zipping them up and attaching them to this issue or by pushing them to a separate repository on GitHub.

Comment From: han1448

I created a simple example in my repo. This application doesn't do anything, it just checks the log which profile is loaded.

When i use spring.profiles.include in application.yaml , the log as follows,

The following profiles are active: profileC,profileB,profileA,default

But i removed spring.profiles.include and added spring.profiles.group, the log as follows

The following profiles are active: default

If the config doesn't work when loaded into configserver , shouldn't these two expected results be the same?

Comment From: wilkinsona

Thanks for the sample. I've reproduced the problem. It's a duplicate of https://github.com/spring-cloud/spring-cloud-config/issues/1876.