Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

aafwu00/routing-datasource-spring

Repository files navigation

License Apache 2.0 Release CircleCI FOSSA Status codacy codecov

Routing DataSource Spring

This project provides Routing Multi DataSource integrations for Spring Boot

Getting Start

Prerequisites

Build

To build the source you will need to install JDK 1.8.

$ ./gradlew build

Usage

  1. Dependency Management

repositories {
    maven { url 'https://jitpack.io' } (1)
}

dependencies {
    compile 'com.github.aafwu00:routing-datasource-spring-boot-starter:x.y.z' (2)
}
  1. add jitpack repository

  2. add dependency

    1. Add the following an annotation to your Spring configuration

`@EnableTransactionManagement`
  1. Write application.yml code

Table 1. Table RoutingDataSourceProperties
Name Default Description

datasource.routing.enabled

false

datasource.routing.type

Whether to choose routing type(Replication, Switchable and MultiRouting)

Table 2. Table SwitchableDataSourceProperties
Name Default Description

datasource.routing.switchOff.*

Switch Off DataSource. Same as spring.datasource.*, See on DataSource Properties

datasource.routing.switchOn.*

Switch On DataSource. Same as spring.datasource.*, See on DataSource Properties

Table 3. Table ReplicationDataSourceProperties
Name Default Description

datasource.routing.master.*

Master DataSource. Same as spring.datasource.*, See on DataSource Properties

datasource.routing.slave.*

Slave DataSource(readOnly = true). Same as spring.datasource.*, See on DataSource Properties

Table 4. Table MappedDataSourceProperties
Name Default Description

datasource.routing.defaults.*

Default DataSource. Same as spring.datasource.*, See on DataSource Properties

datasource.routing.mapped.[key].*

Mapping DataSource. Same as spring.datasource.*, See on DataSource Properties

Table 5. Table MultiRoutingDataSourceProperties
Name Default Description

datasource.routing.targets.[name].*

Multi DataSource. Same as spring.datasource.*, See on DataSource Properties

datasource.routing.multi.[name].standalone

Single DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].master

Replication DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].slave

Replication DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].switchOff

Switchable DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].switchOn

Switchable DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].defaults

Mapped DataSource, Use datasource.routing.targets.[name]

datasource.routing.multi.[name].mapped.[key]

Mapped DataSource, Use datasource.routing.targets.[name]

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Taeho Kim - Initial work - aafwu00

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

FOSSA Status