java - Spring Boot 类路径:指定的资源不存在
问题描述
我正在使用 h2 作为测试数据库。我已经添加了 sql 脚本,/src/main/resources
但是 spring boot 总是失败并显示“指定的资源不存在。 ”错误。以下是配置
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
错误跟踪: https ://paste.ee/p/1kHwd
我在这个平台上引用了很多帖子,并尝试将路径更改为 classpath:/data.sql 但这并不奏效。我在飞行路线上面临同样的问题。不知何故,Spring 在资源中找不到这些脚本。
我在这里错过了什么吗?任何帮助表示赞赏。
解决方案
尝试添加
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
在你的 pom 文件中
推荐阅读
- javascript - POST 方法在 Heroku 中无法使用 MongoDB / Node.js
- python - 安装模型模块的问题
- filter - 根据多个条件组合行,然后对一列求和
- python-3.x - 我们可以将变量传递给python中的文件参数吗?如果是,语法是什么?
- ruby-on-rails - 在 Rails 上创建多对多记录
- sql - 如何使用JOIN、CROSS JOIN将SQL中的全球化存储值合并到一个表中
- angular - 错误类型错误:无法在“FormData”上执行“附加”:参数 2 不是“Blob”类型。角 6
- java - 将现有数据库从资产文件夹复制到设备内存
- html - 如何在反应中添加 defaultprops 或 value
- laravel-5.4 - 在 laravel5.4 中找不到护照 oauth 令牌路径