A Spring Boot 3.5 application demonstrating db-scheduler integration.
- Spring Boot 3.5.9 with Java 25
- db-scheduler 16.6.0 - Persistent task scheduling with database-backed storage
- H2 Database - In-memory database for quick testing
- Flyway - Database migration management
- Gradle 9.2 - Latest Gradle version with Java 25 support
- Example Tasks:
- Recurring heartbeat task (every 30 seconds)
- Recurring cleanup task (every 5 minutes)
- One-time email task (can be scheduled programmatically)
- Java 25 or higher
- Gradle (or use the wrapper)
./gradlew bootRunThe application will start on http://localhost:8080
Access the H2 database console at: http://localhost:8080/h2-console
- JDBC URL:
jdbc:h2:mem:testdb - Username:
sa - Password: (empty)
The project includes comprehensive tests demonstrating db-scheduler functionality:
./gradlew test --tests TimeShiftSchedulerTestAdvanced test that:
- Schedules a task 2 hours in the future
- Manipulates the database to shift time forward by 2 hours
- Verifies the task executes automatically
- Confirms proper cleanup after execution
This test demonstrates how to test time-dependent scheduler behavior without waiting for real time to pass. The test uses SettableClock to manipulate time and verify task execution.
The test covers:
- One-time task execution after time shift
- Recurring task execution and rescheduling after time shift
./gradlew test# Build the project
./gradlew build
# Run tests
./gradlew test
# Create executable JAR
./gradlew bootJarKey dependencies:
spring-boot-starter-data-jdbc- Database accessdb-scheduler-spring-boot-starter- db-scheduler integrationflyway-core- Database migration managementh2- In-memory databaseawaitility- Testing async behavior