https://github.com/thomasvitale/multitenant-spring-boot-demo
https://github.com/thomasvitale/multitenant-spring-boot-demo
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thomasvitale/multitenant-spring-boot-demo
- Owner: ThomasVitale
- License: apache-2.0
- Created: 2023-11-20T15:41:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T21:09:03.000Z (over 1 year ago)
- Last Synced: 2024-10-27T23:38:14.339Z (11 months ago)
- Language: Java
- Size: 65.4 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```bash
./gradlew bootTestRun
```You can directly call the Instrument Service on behalf of a tenant (`dukes` or `beans`), for example, using httpie.
```bash
# 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:
```bash
./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.
```bash
127.0.0.1 dukes.rock
127.0.0.1 beans.rock
```Now open the browser window and navigate to `http://dukes.rock/instruments/`. The result will be the list of instruments from the Dukes rock band.
Now open another browser window and navigate to `http://beans.rock/instruments/`. The result will be the list of instruments from the Beans rock band.