Create a trivial app from start.spring.io and add four properties file like these:

application.yml:

spring:
  config:
    import: classpath:/imported.yml

some:
  property: "value"

application-dev.yml

spring:
  config:
    import: classpath:/imported-dev.yml

some:
  property: "dev-value"

imported.yml

some:
  property: "imported-value"

imported-dev.yml

some:
  property: "imported-dev-value"

Running the app with the dev profile active will cause an error indicating that imported-dev.yml does not exist, when in fact it does.

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data location 'classpath:/imported-dev.yml' does not exist

Action:

Check that the value 'classpath:/imported-dev.yml' at class path resource [application-dev.yml] - 3:13 is correct, or prefix it with 'optional:'

Comment From: ZouHongxue

Hi @scottfrederick I've tried a demo with your config on v2.4.5, it works well. Maybe you could check the compiled file in target/classes.

SpringBoot Config data location does not exist error can be thrown if a profile-specific properties file is directly imported

Comment From: scottfrederick

@ZouHongxue The error shown above happens with this configuration when the dev profile is active. I've edited the description to include this detail. We have written new unit tests to reproduce the problem and are working on a fix.

Comment From: ZouHongxue

@scottfrederick Yup, it happened in dev profile, thanks let me know