SpringBoot version 2.3.0.M4

When trying to set spring.cloud.bootstrap.location (which is effectively mapped to spring.config.location) to something like classpath*:/config/ discovered that it doesn't work because org.springframework.boot.context.config.ConfigFileApplicationListener internally calls org.springframework.util.ResourceUtils#isUrl with supplied location and when receives false prepends it with file:. As a result it ends up with file:classpath*:/config/ in my case, which is obviously incorrect. I filed https://github.com/spring-projects/spring-framework/issues/24979 considering it might be a bug in SpringFramework, but was directed that if pattern support is desirable here then org.springframework.core.io.support.ResourcePatternUtils#isUrl should be used instead.

Comment From: philwebb

At first I thought it would be possible to switch to ResourcePatternUtils.isUrl but I'm afraid it's not that simple. The locations specified in spring.config.location must be exact locations that can be resolved by DefaultResourceLoader. Since we don't want to support wildcards in locations, I'm going to improve the code by throwing a more specific exception.

@vkochnev Is there any reason you can't use classpath:/config/ for your location?

Comment From: vkochnev

Actually my location expected to be classpath*:/config/*/,classpath:/config/. I have several starters shared by several apps and I want them to specify default properties related to this starter, e.g. I want to pre-configure logging, metrics, database, messaging and not copy all these configs over applications. Maybe there is another legit way of doing this, but I cannot see it. In fact I bypassed this check at the moment with specifying location as classpath*:/$config/*/,classpath:/$config/ and looks like it works, but it is a dirty hack and I want some cleaner solution. Also default spring.config.location already contain at least one wildcard file:./config/*/. Finally org.springframework.boot.context.config.ConfigFileApplicationListener.Loader#getResources is called to resolve resources and internally it uses PathMatchingResourcePatternResolver which works just fine with classpath*:. Moreover org.springframework.boot.context.config.ConfigFileApplicationListener.Loader#resourceLoader is not used directly anywhere in Loader except constructor and, I believe, it may be removed from fields at all.

Comment From: philwebb

It looks like we added PathMatchingResourcePatternResolver as part of #19909. I've opened #21217 to discuss that. I'll leave this one as a fix for 2.1.x, since we don't have scanning in that branch.

Please subscribe to #21217 for updates.