Skip to content

wdpimenta/abstract-routing-datasource-multi-tenant

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Multi-tenant demo

This is a good example elaborating multi-tenancy and AbstractRoutingDataSource usage, however it requires pre-defined data sources you cannot add runtime datasources.

Compiling

Run the following command to build the solution:

mvn clean compile package

Running the demo

You're going to need a database which has a structure like this:

CREATE TABLE orders (
    id int not null auto_increment,
    date datetime not null,
    primary key(id)
);

Create a new database per tenant and include a new properties file in the tenants folder in the root of the solution. The contents of this file looks like this:

name=<tenant id>
datasource.url=jdbc:mysql://localhost:3306/<tenant>
datasource.username=
datasource.password=

Next boot up the application using the following command and try it out using SOAPUI, Postman or Curl.

java -jar target/demo-0.0.1-SNAPSHOT.jar

Enjoy!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%