Skip to content

ThomasVitale/multitenant-spring-boot-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Multitenancy

For a more structured example, check my other repo: https://github.com/ThomasVitale/spring-boot-multitenancy.

Stack

  • Java 21
  • Spring Boot 3.2

Usage

The Instrument Service application can be run as follows to rely on Testcontainers to spin up a PostgreSQL database:

./gradlew bootTestRun

You can directly call the Instrument Service on behalf of a tenant (dukes or beans), for example, using httpie.

# Get instruments
http :8181/instruments X-TenantId:dukes
# Add instrument
http :8181/instruments X-TenantId:dukes name="Pearl" type="drums"

The Edge Service application can be run as follows:

./gradlew bootRun

Two tenants are configured: dukes and beans. Ensure you add the following configuration to your hosts file to resolve tenants from DNS names.

127.0.0.1       dukes.rock
127.0.0.1       beans.rock

Now open the browser window and navigate to https://dukes.rock/instruments/. The result will be the list of instruments from the Dukes rock band.

Now open another browser window and navigate to https://beans.rock/instruments/. The result will be the list of instruments from the Beans rock band.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages