File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
main/java/org/springframework/boot/context/config
test/java/org/springframework/boot/context/config Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 54
54
import org .springframework .core .io .Resource ;
55
55
import org .springframework .core .io .ResourceLoader ;
56
56
import org .springframework .util .Assert ;
57
+ import org .springframework .util .ResourceUtils ;
57
58
import org .springframework .util .StringUtils ;
58
59
import org .springframework .validation .BindException ;
59
60
@@ -455,10 +456,10 @@ private Set<String> getSearchLocations() {
455
456
for (String path : asResolvedSet (
456
457
this .environment .getProperty (CONFIG_LOCATION_PROPERTY ), null )) {
457
458
if (!path .contains ("$" )) {
458
- if (!path .contains (":" )) {
459
- path = "file:" + path ;
460
- }
461
459
path = StringUtils .cleanPath (path );
460
+ if (!ResourceUtils .isUrl (path )) {
461
+ path = ResourceUtils .FILE_URL_PREFIX + path ;
462
+ }
462
463
}
463
464
locations .add (path );
464
465
}
Original file line number Diff line number Diff line change @@ -458,6 +458,16 @@ public void specificResourceDefaultsToFile() throws Exception {
458
458
+ location + "]" ));
459
459
}
460
460
461
+ @ Test
462
+ public void absoluteResourceDefaultsToFile () throws Exception {
463
+ String location = new File ("src/test/resources/specificlocation.properties" ).getAbsolutePath ();
464
+ EnvironmentTestUtils .addEnvironment (this .environment , "spring.config.location:"
465
+ + location );
466
+ this .initializer .onApplicationEvent (this .event );
467
+ assertThat (this .environment , containsPropertySource ("applicationConfig: [file:"
468
+ + location .replace (File .separatorChar , '/' ) + "]" ));
469
+ }
470
+
461
471
@ Test
462
472
public void propertySourceAnnotation () throws Exception {
463
473
SpringApplication application = new SpringApplication (WithPropertySource .class );
You can’t perform that action at this time.
0 commit comments