Spring R2dbc Example

January 15, 2026 ยท View on GitHub

The source code is updated to Spring Boot 4/Spring 7/Java 25.

Note

The Spring Boot 3 based version is tagged with a boot-3 tag.

This repository contains the latest changes in the Spring R2dbc(part of Spring Framework 5.3), Spring Data R2dbc 1.2 and Spring Boot 2.4.

I have created several R2dbc examples in the spring-reactive-sample repository since it was born. But Spring Data R2dbc evolved very quickly, thre are plenty of breaking changes introduced since Spring 5.2 and Spring Data R2dbc 1.2.

Compare to the Spring Data R2dbc 1.1, some breaking changes are notable.

  • The old DatabaseClient in Spring Data R2dbc 1.1 was split into two parts, a simple new DatabaseClient is part of Spring framework, as an alternative of Jdbc.
  • Another part of the old DatabaseClient is reorganized into a new class R2dbcEntityTemplate which acts as the role of JdbcTemplate.

Notes

Sample Codes

Spring Boot example

The following example projects are standard Spring Boot projects with Spring Boot autoconfiguration.

ExampleDescription
boot-entitycallbacksSpring Data R2dbc BeforeConvertEntityCallback, AfterConvertEntityCallback, etc.
boot-testcontainersSpring Data R2dbc @DataR2dbcTest with varied Testcontainers configuration.
bootSpring Boot example with R2dbcRepository, R2dbcEntityTemplate and DatabaseClient
boot-oracleSpring Boot with Oracle Example
boot-pg-jsonSpring Boot Example with R2dbc Json and Postgres JSON/JSONB
boot-pg-notifier-listenerSpring Boot Example with Postgres Notifier/Listener
boot-komapperSpring Boot Example with komapper ORM
boot-r2dbc-proxySpring Boot Example with R2dbc Proxy for SQL Logging
boot-filepartSpring Boot FilePart example, Postgres bytea type mapping to byte[], ByteBuffer, R2dbc Blob
boot-r2dbc-migrateR2dbc Migrate example
boot-auditingSpring Data R2dbc Auditing example
boot-kotlin-coKotlin Coroutines example with CoroutinesRepository
boot-jooqR2dbc and JOOQ example
boot-jooq-kotlin-co-gradleR2dbc/JOOQ/Kotlin Coroutines and Gradle generator config example
bookstore(WIP) An example to track the associations support of Spring Data R2dbc

Spring Examples

The following example projects use Spring Boot to manage the dependencies, but configure R2dbc/Data R2dbc from scratch.

ExampleDescription
connection-factoriesR2dbc driver's ConnectionFactory examples for MySQL, H2, PostgreSQL, MSSQL, Oracle, etc
database-clientSpring R2dbc DatabaseClient example
data-r2dbc-entitytemplatesSpring Data R2dbc R2dbcEntityTemplate example
data-r2dbc-repositoriesSpring Data R2dbc R2dbcRepository interface example

Reference