By default, @ActiveProfile
annotation for tests overrides profiles defined either in the environment or as a system property.
I have seen commit https://github.com/spring-projects/spring-boot/commit/49921d65acd29a9704c2dd54ef405d6654dcb321#diff-d40f7ea27388f091b15f8e2b1333f4a7bf1d21f8c53aff7226183a7d8cf6be7c trying to prevent loading incorrect profiles.
However, this does not prevent another ApplicationListener to create the wrong environment. An example is Spring Cloud dependancy in the Spring Boot Project. Class org.springframework.cloud.bootstrap.BootstrapApplicationListener
creates new context with an imperfect copy of the environment (it does not set active profiles, so they are determined from property spring.profiles.active
and then registers ApplicationContextInitializer
that merges it with the context.
Comment From: mbhave
BootstrapApplicationListener
is part of Spring Cloud. You can create an issue in Spring Cloud's issue tracker. When you do, please provide a minimal sample that the team can run to reproduce the issue.