/spring-boot-r2dbc

Experimental Spring Boot support for R2DBC

Primary LanguageJavaApache License 2.0Apache-2.0

Spring Boot R2DBC Starter

This experimental project provides a simple way to try the new R2DBC support through R2DBC Client and Spring Data R2DBC.

Starters

  • spring-boot-starter-r2dbc: Starter using R2DBC Client.

  • spring-boot-starter-data-r2dbc: Starter using Spring Data R2DBC

Supported Drivers

H2 (Embedded)

Dependencies:

<dependency>
  <groupId>io.r2dbc</groupId>
  <artifactId>r2dbc-h2</artifactId>
</dependency>

Configuration embedded mode:

application.properties
# Nothing to do here.
Note
Spring Boot has support for embedded H2 databases using the JDBC interfacing option. Spring Boot’s R2DBC configuration picks up H2 configuration details to ensure all R2DBC operations are executed on the same database instance.

Configuration in-memory:

application.properties
spring.r2dbc.url=rdbc:h2:mem:///<database>?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.r2dbc.username=…
spring.r2dbc.password=…

Configuration file:

application.properties
spring.r2dbc.url=rdbc:h2:file:///<path>/<to>/<database>?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.r2dbc.username=…
spring.r2dbc.password=…

PostgreSQL

Dependencies:

<dependency>
  <groupId>io.r2dbc</groupId>
  <artifactId>r2dbc-postgresql</artifactId>
</dependency>

Configuration:

application.properties
spring.r2dbc.url=rdbc:postgresql://<server>:<port>/<database>
spring.r2dbc.username=…
spring.r2dbc.password=…

SQL Server

Dependencies:

<dependency>
  <groupId>io.r2dbc</groupId>
  <artifactId>r2dbc-mssql</artifactId>
</dependency>

Configuration:

application.properties
spring.r2dbc.url=rdbc:mssql://<server>:<port>/<database>
spring.r2dbc.username=…
spring.r2dbc.password=…