mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Document that spring.profiles.active is ignored by @ActiveProfiles
The Spring TestContext Framework does not honor the `spring.profiles.active` system property when determining active profiles for a test class if @ActiveProfiles is used. This commit documents that behavior in the @ActiveProfiles and DefaultActiveProfilesResolver Javadoc, as well as in the reference manual. A SystemPropertyActiveProfilesResolver example is also added showing how to allow `spring.profiles.active` to override @ActiveProfiles. See gh-36269 Closes gh-36600 Signed-off-by: Mohak Nagaraju <98132980+Mohak-Nagaraju@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,16 @@ import org.springframework.core.annotation.AliasFor;
|
||||
* <p>This annotation will be inherited from an enclosing test class by default.
|
||||
* See {@link NestedTestConfiguration @NestedTestConfiguration} for details.
|
||||
*
|
||||
* <p>Note that when {@code @ActiveProfiles} is declared on a test class, the
|
||||
* {@code spring.profiles.active} property (whether configured as a JVM system
|
||||
* property or environment variable) is not taken into account by the Test Context
|
||||
* Framework when determining active profiles. If you need to allow
|
||||
* {@code spring.profiles.active} to override the profiles configured via
|
||||
* {@code @ActiveProfiles}, you can implement a custom {@link ActiveProfilesResolver}
|
||||
* and register it via the {@link #resolver} attribute. See
|
||||
* <em>Context Configuration with Environment Profiles</em> in the reference manual
|
||||
* for further details and examples.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
* @see SmartContextLoader
|
||||
|
||||
+6
@@ -32,6 +32,12 @@ import static org.springframework.test.context.TestContextAnnotationUtils.findAn
|
||||
* configured declaratively via {@link ActiveProfiles#profiles} or
|
||||
* {@link ActiveProfiles#value}.
|
||||
*
|
||||
* <p>Note that the {@code spring.profiles.active} property (whether configured
|
||||
* as a JVM system property or environment variable) is not taken into account by
|
||||
* this resolver. If you need to allow {@code spring.profiles.active} to override
|
||||
* profiles configured via {@link ActiveProfiles}, you can implement a custom
|
||||
* {@link ActiveProfilesResolver} and register it via {@link ActiveProfiles#resolver}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.1
|
||||
* @see ActiveProfiles
|
||||
|
||||
Reference in New Issue
Block a user