I have this configuration in a spring boot application:
spring:
application:
name: my-app
profiles:
active: ${ENVIRONMENT}
cloud:
config:
uri: http://localhost:8888
My config server reads the following files:
my-app-dev.yaml
prop: dev property
my-app-pro.yaml
prop: pro property.
I launch the spring boot app setting -DENVIRONMENT=dev, loading correctly the dev external Git properties.
When I inject the Environment in let's say a controller and do env.getActiveProfiles() I get "dev" as expected.
I would like to add more profiles from the git configuration. For instance:
my-app-dev.yaml
prop: dev property
spring:
active:
profiles: dev,business1
my-app-pro.yaml
prop: dev property
spring:
active:
profiles: pro,business2
So that env.getActiveProfiles() returns ["dev","business1"]. However what it returns is the initial "dev".
How could this be done?
UPDATE:
As suggested by Dave Syer I tried using spring.profiles.include in the Git files but the new profiles aren't added to the Environment:
my-app-dev.yaml
prop: dev property
spring:
profiles:
include: business1
my-app-pro.yaml
prop: dev property
spring:
profiles:
include: business2
environment.getActiveProfiles() ---> "dev"
spring.profiles.include(docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/…)? - Dave SyerEnvironment.getActiveProfiles()returns only the original${ENVIRONMENT}(dev) profile. - codependentmy-app-business1.ymlin the result. - Dave Syerenv.getActiveProfiles()returns bothdevcoming from the app internal application.yml (spring: active: profiles: dev) andbusiness1from Git myapp-dev.yaml (spring: profiles: include: business1). Maybe there's something wrong with my proyect. I'll start from scratch with a basic Spring Boot app to check it again and make it available in GitHub in case it doesn't work. - codependent