Spring Data YugabyteDB Beta

The Spring Data YugabyteDB driver brings the power of distributed SQL to Spring developers by using the YugabyteDB JDBC Driver. The end result is that most features of PostgreSQL v11.2 are now available as a massively-scalable, fault-tolerant distributed database. Spring Data YugabyteDB is based on Spring Data JPA.

Unique Features

In addition to providing most PostgreSQL features on top of a scalable and resilient distributed database, this project aims to enable the following:

  • Eliminate load balancer from SQL (cluster-awareness)
  • Develop geo-distributed Apps (topology-awareness)
  • Row level geo-partitioning support (partition-awareness)

Go to the Spring Data YugabyteDB GitHub project to watch, star, file issues, and contribute.

Getting Started

Maven configuration

Add the Maven dependency:

  1. <dependency>
  2. <groupId>com.yugabyte</groupId>
  3. <artifactId>spring-data-yugabytedb</artifactId>
  4. <version>2.1.10-yb-1</version>
  5. </dependency>

Data source configuration

To enable the YugabyteDB configuration, create configuration class:

  1. @Configuration
  2. public class DatabaseConfiguration extends AbstractYugabyteConfiguration {
  3. // Here you can override the dataSource() method to configure the DataSource in code.
  4. }

Configure your application.properties. For instance:

  1. spring.yugabyte.initialHost=localhost
  2. spring.yugabyte.port=5433
  3. spring.yugabyte.database=yugabyte
  4. spring.yugabyte.user=yugabyte
  5. spring.yugabyte.password=yugabyte
  6. spring.yugabyte.maxPoolSizePerNode=8
  7. spring.yugabyte.connectionTimeoutMs=10000
  8. spring.yugabyte.generate-ddl=true
  9. spring.yugabyte.packages-to-scan=com.example.spring.jpa.springdatajpaexample.domain

To learn more about using the Spring Data YugabyteDB module, see Spring Data YugabyteDB example.