This project brings the power of Distributed SQL to Spring developers by using an enhanced underlying JDBC driver - which brings most features of PostgreSQL (as of v11.2) into a distributed database that is scalable and fault-tolerant. This project is based on Spring Data JPA.
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)
Add the Maven dependency:
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>spring-data-yugabytedb</artifactId>
<version>2.1.10-yb-1</version>
</dependency>
To enable the YugabyteDB configuration create configuration class:
@Configuration
public class DatabaseConfiguration extends AbstractYugabyteConfiguration {
// Here you can override the dataSource() method to configure the DataSource in code.
}
Configure your application.properties
. For instance:
spring.yugabyte.initialHost=localhost
spring.yugabyte.port=5433
spring.yugabyte.database=yugabyte
spring.yugabyte.user=yugabyte
spring.yugabyte.password=yugabyte
spring.yugabyte.maxPoolSizePerNode=8
spring.yugabyte.connectionTimeoutMs=10000
spring.yugabyte.generate-ddl=true
spring.yugabyte.packages-to-scan=com.example.spring.jpa.springdatajpaexample.domain
See also the spring-data-yugabytedb-example app.