Improve documentation for the default profile

Closes gh-29071
This commit is contained in:
Stéphane Nicoll 2023-10-25 11:20:21 +02:00
parent 925fa0272b
commit 84c28995fb
3 changed files with 15 additions and 6 deletions

View File

@ -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.

View File

@ -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.
*
* <p>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.
*
* <p>The {@code @Profile} annotation may be used in any of the following ways:
* <ul>
* <li>as a type-level annotation on any class directly or indirectly annotated with

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@ -89,7 +89,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
/**
* Name of reserved default profile name: {@value}. If no default profile names are
* explicitly and no active profile names are explicitly set, this profile will
* explicitly set and no active profile names are explicitly set, this profile will
* automatically be activated by default.
* @see #getReservedDefaultProfiles
* @see ConfigurableEnvironment#setDefaultProfiles
@ -97,7 +97,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
* @see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
* @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
*/
protected static final String RESERVED_DEFAULT_PROFILE_NAME = "default";
public static final String RESERVED_DEFAULT_PROFILE_NAME = "default";
protected final Log logger = LogFactory.getLog(getClass());