diff --git a/framework-docs/modules/ROOT/pages/core/beans/environment.adoc b/framework-docs/modules/ROOT/pages/core/beans/environment.adoc index a585f3b10f..571688d20c 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/environment.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/environment.adoc @@ -562,8 +562,9 @@ If no profile is active, the `dataSource` is created. You can see this as a way to provide a default definition for one or more beans. If any profile is enabled, the default profile does not apply. -You can change the name of the default profile by using `setDefaultProfiles()` on -the `Environment` or, declaratively, by using the `spring.profiles.default` property. +The name of the default profile is `default`. You can change the name of +the default profile by using `setDefaultProfiles()` on the `Environment` or, +declaratively, by using the `spring.profiles.default` property. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Profile.java b/spring-context/src/main/java/org/springframework/context/annotation/Profile.java index 2dae20439a..b128bf9208 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Profile.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Profile.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,14 @@ import org.springframework.core.env.Profiles; * for web applications. Profiles may also be activated declaratively in * integration tests via the {@code @ActiveProfiles} annotation. * + *
If no profile is active using one of those options, a default profile is + * enabled as a fallback. The name of the default profile is + * {@value AbstractEnvironment#RESERVED_DEFAULT_PROFILE_NAME}. This can be changed + * via {@link ConfigurableEnvironment#setDefaultProfiles} or declaratively by + * setting the {@link AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME + * spring.profiles.default} property as a JVM system property, as an environment + * variable, or as a Servlet context parameter in {@code web.xml} for web applications. + * *
The {@code @Profile} annotation may be used in any of the following ways: *