我正在尝试运行Spring批处理应用程序来创建批处理作业。
我的application.properties如下图所示:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:localhost;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=admin
spring.datasource.password=p@ssw0rd
spring.datasource.schema=schema-hsqldb.sql我得到的错误如下:
Caused by: org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException: Property spring.datasource.schema with value 'class path resource [schema-hsqldb.sql]' is invalid: The specified resource does not exist.据我所知,schema-hsqldb.sql存在于类路径/org/springframework/batch/core/schema-hsqldb.sql中。
当我注释掉spring.datasource.schema=schema-hsqldb.sql时,Spring boot应用程序就可以工作了。是否必须手动导入SQL脚本?如果是这样,我该怎么做呢?
发布于 2020-02-03 18:29:17
您的问题是,您正在使用具有HSQL模式的H2驱动程序。H2和HSQL是不同的产品。您还需要使用H2的模式:
spring.datasource.schema=/org/springframework/batch/core/schema-h2.sql也就是说,您不需要使用Spring Boot为嵌入式数据库配置数据源,数据源将自动配置。以下是参考文档的Embedded Database Support部分的摘录:
HSQL可以自动配置嵌入式H2、
和Derby数据库。您不需要提供任何连接URL。您只需包含对要使用的嵌入式数据库的构建依赖项。
https://stackoverflow.com/questions/60037126
复制相似问题