使用HSQL数据库运行Quartz调度器时遇文件不存在错误
Hey, let's work through this error together! The root issue here is that your Spring application can't locate the tables_hsqldb.sql script that Quartz needs to initialize its database tables in HSQLDB. Here are the most common fixes:
1. Verify your Quartz dependency setup
First, make sure you've included the full Quartz dependencies in your build file. Sometimes, a minimal Quartz dependency might not include the database initialization scripts.
For Maven, ensure your pom.xml has something like this:
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.3.2</version> <!-- Use a stable, compatible version --> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz-jobs</artifactId> <version>2.3.2</version> </dependency>
For Gradle:
implementation 'org.quartz-scheduler:quartz:2.3.2' implementation 'org.quartz-scheduler:quartz-jobs:2.3.2'
After updating dependencies, do a clean build to ensure all jars are downloaded correctly.
2. Check if the script exists in your Quartz jar
Navigate to the Quartz jar in your project's dependency folder (e.g., ~/.m2/repository/org/quartz-scheduler/quartz/2.3.2/quartz-2.3.2.jar) and open it to verify if org/quartz/impl/jdbcjobstore/tables_hsqldb.sql is present. If it's missing, you might have a corrupted jar or an incompatible version—try re-downloading the dependency or switching to a different stable version of Quartz.
3. Manually add the script to your classpath
If the script isn't in the Quartz jar for some reason, you can grab the official tables_hsqldb.sql file and place it in your project's src/main/resources/org/quartz/impl/jdbcjobstore/ directory. This will make it available on the classpath for Spring to find.
4. Double-check your Spring configuration
If you've customized the Quartz data source initialization in your Spring config (e.g., using a DataSourceInitializer bean), ensure you haven't accidentally misspelled the script path. The default path that Spring looks for is exactly org/quartz/impl/jdbcjobstore/tables_hsqldb.sql, so any typos here would cause the error.
Give these steps a try—most often, the issue is just a missing or misconfigured dependency. Let me know if you run into more trouble!
内容的提问来源于stack exchange,提问作者Maciaz

