The process of Multi Tenant in Spring Boot and JPA is to use the dynamic routing data source.

For each tenant, there is a datasource property file.

Could put all such files under a all tenants folder, when creating a new tenant, create such a property file too.

Then config JPA to use this routing datasource with look up key.

In JWT, create a filter, the tenantId is contained in the claims. After decryption of the JWT header, create a static tenant class that has threadlocal variable tenantId.

So, JPA will save data based on the routing configuration. That's it.





refs:


https://www.baeldung.com/multitenancy-with-spring-data-jpa


没有登录不能评论