Relax profile naming restrictions and allow opt-out

Rework profile name validation logic so that `.` and `+` and `@` can
be used in the names. Also provide an opt-out property that can be
set to restore earlier Spring Boot behavior.

The commit also include an update to the reference documentation.

Fixes gh-45947
This commit is contained in:
Phillip Webb
2025-06-13 11:54:05 -07:00
parent 302a6e823f
commit 7613594b3a
11 changed files with 378 additions and 118 deletions

View File

@@ -59,6 +59,22 @@ This means that you can specify active profiles in `application.properties` and
TIP: See xref:features/external-config.adoc#features.external-config.order[the "`Externalized Configuration`"] for more details on the order in which property sources are considered.
[NOTE]
====
By default, profile names in Spring Boot may contain letters, numbers, or permitted characters (`-`, `_`, `.`, `+`, `@`).
In addition, they can only start and end with a letter or number.
This restriction helps to prevent common parsing issues.
if, however, you prefer more flexible profile names you can set configprop:spring.profiles.validate[] to `false` in your `application.properties` or `application.yaml` file:
[configprops,yaml]
----
spring:
profiles:
validate: false
----
====
[[features.profiles.adding-active-profiles]]