An embedded reactive database test must use a driver and database engine version that agree at the binary API level.
Spring R2DBC fixture isolation: keep incompatible H2 versions out of one test classpath
Make the dependency boundary visible
The main Spring source kit pins H2 2.3.232 for long-standing JDBC examples. Boot 4.0.8 manages r2dbc-h2 1.1.0.RELEASE with H2 2.4.240. Placing the reactive driver on the original test classpath produced a NoSuchMethodError before any SQL ran. The fixture now lives in reactive-r2dbc, a separate Maven project inside the same download, so its managed H2 pair can be tested without changing earlier JDBC results. This is a binary compatibility finding, not a reason to silently bump the entire course's database baseline.
Run mvn test in both directories. The reactive project has six H2 checks for subscription timing, value binding, commit, rollback, stale version and wrong tenant. Its direct DatabaseClient calls do not start Boot, WebFlux or a connection pool. The testing guide explains why passing those local checks cannot establish deployment behavior.
Promote the actual database contract separately
Production databases differ in locking, isolation, statement timeout, connection cleanup and error translation. Re-run the conditional update and rollback cases against the intended engine with concurrent sessions. Check cancellation while a transaction is open, and measure pool saturation under load. The isolated H2 test is a fast contract probe, not a production certification.
Checked excerpt
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
</dependency>Verification boundary
The Java 21 / Spring Boot 4 source kit checks all six methods in the nested reactive-r2dbc Maven project; the main source-kit tests run on their existing JDBC dependency graph.
Cost and limits
Two small Maven projects require two test commands and a larger source download. That cost is explicit and avoids a misleading green suite assembled from incompatible H2 libraries.
Common Mistakes
- Do not hide a NoSuchMethodError by skipping reactive tests.
- Do not upgrade the JDBC fixture's database without rechecking its published examples.
- Do not treat embedded H2 behavior as proof of production database concurrency.
Read next
Spring R2DBC subscription boundary: constructing SQL does not execute it, Spring R2DBC reactive transaction: roll back the event marker with a rejected debit, Spring tests: separate business rules, wiring and transport, Spring transaction isolation: state the anomaly you need to prevent, Spring JdbcTemplate: bound values and visible database constraints.
