In my app's application.yaml I have

spring:
  config:
    import: file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/*/

The directory /Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files looks like this

~ ls -l /Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files
total 48
-rw-r--r--  1 ryanjbaxter  staff  646 May  6 21:03 application.yml
-rw-r--r--  1 ryanjbaxter  staff  483 May  6 21:02 blueorgreen.yml
-rw-r--r--  1 ryanjbaxter  staff   17 Apr 21 11:16 blueorgreenauthgateway.yml
-rw-r--r--  1 ryanjbaxter  staff   24 Apr 21 11:16 blueorgreenfrontend-local.yml
-rw-r--r--  1 ryanjbaxter  staff   86 Apr 22 13:46 blueorgreenfrontend.yml
-rw-r--r--  1 ryanjbaxter  staff  108 Apr 21 11:16 blueorgreengateway.yml

For some reason Boot thinks the directory is empty and then throws this exception

java.lang.IllegalStateException: Location 'file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/*/' must not be a pattern
    at org.springframework.util.Assert.state(Assert.java:97)
    at org.springframework.boot.context.config.LocationResourceLoader.validateNonPattern(LocationResourceLoader.java:84)
    at org.springframework.boot.context.config.LocationResourceLoader.getResource(LocationResourceLoader.java:75)
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolveEmptyDirectories(StandardConfigDataLocationResolver.java:247)
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:237)
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:126)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:107)
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101)
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:242)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:230)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:375)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
    at org.springframework.demo.BlueOrGreenApplication.main(BlueOrGreenApplication.java:14)

Comment From: wilkinsona

As described here, your import is instructing Spring Boot to import files from every directory in /Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/, but it only contains files so nothing is found. It would find your application.yml file if it was moved down into a sub-directory of config-files.

We might be able to improve the error a bit as I agree that it's not very clear at the moment.

Comment From: ryanjbaxter

That behavior seems odd to me. It's not would I would expect, and its not terribly clear to me in the documentation that only files in subdirectories would be picked up. So if I had files in the top level director and in subdirectories I would have to do this?

spring:
  config:
    import: file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/*/,file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/

In addition to improving the error I would also think we might be able to make the docs a bit clearer on the behavior.

Comment From: wilkinsona

Yes, that's right. If config-files/*/ picked up files in both config-files/ and in all sub-directories of config-files/, there would be no way to only pick up one or the other.

The documentation already reads quite clearly to me, particularly this sentence:

By default, Spring Boot includes config/*/ in the default search locations. It means that all subdirectories of the /config directory outside of your jar will be searched.

Reading that, it's clear to me that that config/*/ won't cause config/ to be searched.

Comment From: ryanjbaxter

OK well I guess it was just not obvious to me. Thanks for updating the error message!