[英]Spring boot classpath: The specified resource does not exist
I am using h2 as a database for testing.我正在使用 h2 作为测试数据库。 I have added sql scripts to /src/main/resources
but spring boot always fails with " The specified resource does not exist. " error.我已将 sql 脚本添加到/src/main/resources
但 spring 引导始终失败,并显示“指定的资源不存在。 ”错误。 Following are the configurations以下是配置
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.initialize=true
spring.datasource.schema=classpath:schema.sql
spring.datasource.data=classpath:data.sql
ErrorTrace: https://paste.ee/p/1kHwd错误跟踪: https://paste.ee/p/1kHwd
I have referred many posts on this platform and tried changing the path to classpath:/data.sql but this did not work as well.我在这个平台上引用了很多帖子,并尝试将路径更改为 classpath:/data.sql 但这也不起作用。 I am facing the same issue with the flyway.我在飞行路线上面临同样的问题。 Somehow Spring can not found these scripts in resources.不知何故 Spring 在资源中找不到这些脚本。
Am I missing something here?我在这里错过了什么吗? Any help is appreciated.任何帮助表示赞赏。
try to add尝试添加
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
in your pom file在你的 pom 文件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.