spring.sql.init.schema-locations 不工作

Ken*_*ton 6 sql schema spring-data-jpa spring-boot

我使用配置文件来确定要使用哪个数据连接器(dev=h2,prod=mySQL)。我正在尝试使用

spring.sql.init.schema-locations=
Run Code Online (Sandbox Code Playgroud)

要将位置设置为具有活动配置文件中的属性的相关路径,但我不断收到:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: 
Invocation of init method failed; nested exception is java.lang.IllegalStateException: No schema scripts found at location './database/h2/schema-h2.sql'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar:5.3.15]
Run Code Online (Sandbox Code Playgroud)

无论我将该属性指向何处,都会出现相同的错误。

是否有任何其他特殊语法来声明此属性的资源下的哪个文件或哪个目录?当我在 Idea 中编辑此属性时,自动完成功能会愉快地显示文件夹/文件结构,但 Spring 看不到我所指向的内容!

Ken*_*ton 3

根据上面@Andy Wilkinson 的评论回答:

添加 classpath: 作为前缀解决了该问题。