Skip to content

Commit c36d529

Browse files
committed
Merge branch '3.3.x'
Closes gh-42673
2 parents 2728344 + 4d29800 commit c36d529

File tree

5 files changed

+66
-1
lines changed
  • spring-boot-project/spring-boot-docs/src

5 files changed

+66
-1
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc

+18
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,24 @@ For example, the configuration property `my.service[0].other` would use an envir
962962
Support for binding from environment variables is applied to the `systemEnvironment` property source and to any additional property source whose name ends with `-systemEnvironment`.
963963

964964

965+
966+
[[features.external-config.typesafe-configuration-properties.relaxed-binding.maps-from-environment-variables]]
967+
==== Binding Maps from environment variables
968+
969+
When Spring Boot binds an environment variable to a property class, it lowercases the environment variable name before binding.
970+
Most of the time this detail isn't important, except when binding to `Map` properties.
971+
972+
The keys in the `Map` are always in lowercase, as seen in the following example:
973+
974+
include-code::MyMapsProperties[]
975+
976+
When setting `MY_PROPS_VALUES_KEY=value`, the `values` `Map` contains a `{"key"="value"}` entry.
977+
978+
Only the environment variable *name* is lower-cased, not the value.
979+
When setting `MY_PROPS_VALUES_KEY=VALUE`, the `values` `Map` contains a `{"key"="VALUE"}` entry.
980+
981+
982+
965983
[[features.external-config.typesafe-configuration-properties.relaxed-binding.caching]]
966984
==== Caching
967985

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/logging.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ It is also possible to set logging levels using environment variables.
222222
For example, `LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG` will set `org.springframework.web` to `DEBUG`.
223223

224224
NOTE: The above approach will only work for package level logging.
225-
Since relaxed binding always converts environment variables to lowercase, it is not possible to configure logging for an individual class in this way.
225+
Since relaxed binding xref:features/external-config.adoc#features.external-config.typesafe-configuration-properties.relaxed-binding.maps-from-environment-variables[always converts environment variables to lowercase], it is not possible to configure logging for an individual class in this way.
226226
If you need to configure logging for a class, you can use xref:features/external-config.adoc#features.external-config.application-json[the `SPRING_APPLICATION_JSON`] variable.
227227

228228

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/ssl.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ When used to secure a client-side connection, a `truststore` is typically config
4545

4646
See javadoc:org.springframework.boot.autoconfigure.ssl.JksSslBundleProperties[] for the full set of supported properties.
4747

48+
NOTE: If you're using environment variables to configure the bundle, the name of the bundle is xref:features/external-config.adoc#features.external-config.typesafe-configuration-properties.relaxed-binding.maps-from-environment-variables[always converted to lowercase].
49+
4850

4951

5052
[[features.ssl.pem]]
@@ -109,6 +111,8 @@ The following example shows how a truststore certificate can be defined:
109111

110112
See javadoc:org.springframework.boot.autoconfigure.ssl.PemSslBundleProperties[] for the full set of supported properties.
111113

114+
NOTE: If you're using environment variables to configure the bundle, the name of the bundle is xref:features/external-config.adoc#features.external-config.typesafe-configuration-properties.relaxed-binding.maps-from-environment-variables[always converted to lowercase].
115+
112116

113117

114118
[[features.ssl.applying]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.relaxedbinding.mapsfromenvironmentvariables;
18+
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
import org.springframework.boot.context.properties.ConfigurationProperties;
23+
24+
@ConfigurationProperties(prefix = "my.props")
25+
public class MyMapsProperties {
26+
27+
private final Map<String, String> values = new HashMap<>();
28+
29+
public Map<String, String> getValues() {
30+
return this.values;
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.relaxedbinding.mapsfromenvironmentvariables
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties
4+
5+
@ConfigurationProperties(prefix = "my.props")
6+
class MyMapsProperties {
7+
8+
val values: Map<String, String> = HashMap()
9+
10+
}

0 commit comments

Comments
 (0)