You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor `ConfigData` processing code to make it less awkward to
follow.
Prior to this commit the `ConfigDataLocationResolver` would take a
String location and return a `ConfigDataLocation` instance. This was
a little confusing since sometimes we would refer to `location` as the
String value, and sometimes it would be the typed instance. We also
had nowhere sensible to put the `optional:` prefix logic and we needed
to pass a `boolean` parameter to a number of methods. The recently
introduced `Orgin` support also didn't have a good home.
To solve this, `ConfigDataLocation` has been renamed to
`ConfigDataResource`. This frees up `ConfigDataLocation` to be used
as a richer `location` type that holds the String value, the `Orgin`
and provides a home for the `optional:` logic.
This commit also cleans up a few other areas of the code, including
renaming `ResourceConfigData...` to `StandardConfigData...`. It also
introduces a new exception hierarchy for `ConfigDataNotFoundExceptions`.
Closesgh-23711
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
+1-1
Original file line number
Diff line number
Diff line change
@@ -663,7 +663,7 @@ You can use this prefix with the `spring.config.location` and `spring.config.add
663
663
664
664
For example, a `spring.config.import` value of `optional:file:./myconfig.properties` allows your application to start, even if the `myconfig.properties` file is missing.
665
665
666
-
If you want to ignore all `ConfigDataLocationNotFoundExceptions` and always continue to start your application, you can use the `spring.config.on-location-not-found` property.
666
+
If you want to ignore all `ConfigDataLocationNotFoundExceptions` and always continue to start your application, you can use the `spring.config.on-not-found` property.
667
667
Set the value to `ignore` using `SpringApplication.setDefaultProperties(...)` or with a system/environment variable.
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironment.java
+40-27
Original file line number
Diff line number
Diff line change
@@ -48,10 +48,10 @@
48
48
* Wrapper around a {@link ConfigurableEnvironment} that can be used to import and apply
49
49
* {@link ConfigData}. Configures the initial set of
50
50
* {@link ConfigDataEnvironmentContributors} by wrapping property sources from the Spring
51
-
* {@link Environment} and adding the initial set of imports.
51
+
* {@link Environment} and adding the initial set of locations.
52
52
* <p>
53
-
* The initial imports can be influenced via the {@link #LOCATION_PROPERTY},
54
-
* {@value #ADDITIONAL_LOCATION_PROPERTY} and {@value #IMPORT_PROPERTY} properties. If not
53
+
* The initial locations can be influenced via the {@link #LOCATION_PROPERTY},
54
+
* {@value #ADDITIONAL_LOCATION_PROPERTY} and {@value #IMPORT_PROPERTY} properties. If no
55
55
* explicit properties are set, the {@link #DEFAULT_SEARCH_LOCATIONS} will be used.
56
56
*
57
57
* @author Phillip Webb
@@ -76,28 +76,41 @@ class ConfigDataEnvironment {
76
76
77
77
/**
78
78
* Property used to determine what action to take when a
79
-
* {@code ConfigDataLocationNotFoundException} is thrown.
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributor.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorPlaceholdersResolver.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributors.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessor.java
+2-2
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,9 @@ public class ConfigDataEnvironmentPostProcessor implements EnvironmentPostProces
53
53
/**
54
54
* Property used to determine what action to take when a
55
55
* {@code ConfigDataLocationNotFoundException} is thrown.
0 commit comments