Autoconfiguration of HA-JDBC components for Spring Boot
Just include this project as as dependency in your Spring Boot project and add the configuration for the backend databases in your application properties.
hajdbc:
driverDatabases:
- id: db1
location: jdbc:hsqldb:mem:db1
user: sa
- id: db1
location: jdbc:hsqldb:mem:db1
user: sa
spring:
datasource:
url: jdbc:ha-jdbc:default
username: sa
hajdbc.driverDatabases[0].id=db1
hajdbc.driverDatabases[0].location=jdbc:hsqldb:mem:db1
hajdbc.driverDatabases[0].user=sa
hajdbc.driverDatabases[1].id=db2
hajdbc.driverDatabases[1].location=jdbc:hsqldb:mem:db2
hajdbc.driverDatabases[1].user=sa
spring.datasource.url=jdbc:ha-jdbc:default
spring.datasource.username=sa
By default, this integration uses default factory implementations for the state manager, database metadata cache and balancer. If you provide your own implementation as a bean, the integration will pick those over the default. If for example you want to use a SQLite state manager, just create a bean like this in your configuration:
@Bean
public StateManagerFactory stateManagerFactory() {
return new SQLiteStateManagerFactory();
}
By default. the integration will use a SimpleStateManagerFactory, a RoundRobinBalancerFactory and a SharedEagerDatabaseMetaDataCacheFactory.
All configurable properties are prefixed with hajdbc. The following properties are configurable for this integration: