Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4e0fdbee
Commit
4e0fdbee
authored
Apr 21, 2020
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process additional locations when non-default location configured
Fixes gh-20745
parent
af6d5387
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+6
-4
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+10
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
4e0fdbee
...
...
@@ -622,12 +622,14 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
private
Set
<
String
>
getSearchLocations
()
{
Set
<
String
>
locations
=
getSearchLocations
(
CONFIG_ADDITIONAL_LOCATION_PROPERTY
);
if
(
this
.
environment
.
containsProperty
(
CONFIG_LOCATION_PROPERTY
))
{
return
getSearchLocations
(
CONFIG_LOCATION_PROPERTY
);
locations
.
addAll
(
getSearchLocations
(
CONFIG_LOCATION_PROPERTY
));
}
else
{
locations
.
addAll
(
asResolvedSet
(
ConfigFileApplicationListener
.
this
.
searchLocations
,
DEFAULT_SEARCH_LOCATIONS
));
}
Set
<
String
>
locations
=
getSearchLocations
(
CONFIG_ADDITIONAL_LOCATION_PROPERTY
);
locations
.
addAll
(
asResolvedSet
(
ConfigFileApplicationListener
.
this
.
searchLocations
,
DEFAULT_SEARCH_LOCATIONS
));
return
locations
;
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
4e0fdbee
...
...
@@ -913,6 +913,16 @@ class ConfigFileApplicationListenerTests {
assertThat
(
this
.
environment
.
getProperty
(
"value"
)).
isEqualTo
(
"1234"
);
}
@Test
void
additionalLocationWhenLocationConfiguredShouldTakesPrecedenceOverConfiguredLocation
()
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.config.location=classpath:some.properties"
,
"spring.config.additional-location=classpath:override.properties"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getProperty
(
"foo"
)).
isEqualTo
(
"bar"
);
assertThat
(
this
.
environment
.
getProperty
(
"value"
)).
isNull
();
}
@Test
void
locationReplaceDefaultLocation
()
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment