Since July 16, 2024 The druid-multi-tenant-starter plugin has been released for more than two years. The launch of this new tool marks the birth of an efficient and convenient SaaS multi-tenant management solution, providing developers with a brand new convenient experience.
druid-multi-tenant-starter is a multi-tenant plugin based on MyBatis interceptor and alibaba Druid SQL parser. It aims to simplify multi-tenant management in SaaS (Software as a Service) platforms, providing an out-of-the-box and easy-to-configure solution, enabling developers to easily achieve multi-tenant data isolation and management.
Seamless Integration: As an out-of-the-box plugin, druid-multi-tenant-starter can be perfectly integrated with the existing MyBatis framework, avoiding cumbersome configuration and code modifications. Only a small amount of configuration is required to enable multi-tenant functionality, greatly enhancing the development efficiency.
Powerful SQL Parsing: Utilizing the powerful SQL parsing ability of alibaba Druid, druid-multi-tenant-starter can accurately parse and process SQL statements, ensuring data isolation and security in a multi-tenant environment. Whether it is a query, update or deletion operation, it can be effectively managed and controlled.
Flexible Tenant Management: The plugin provides a variety of flexible tenant management strategies, allowing developers to define and adjust the tenant identification method according to actual needs. This makes it able to adapt to different application scenarios and provide personalized solutions.
Performance Optimization: druid-multi-tenant-starter parses SQL statements based on the alibaba Druid SQL parsing library, and its performance is stronger than that of a certain tenant plugin which parses SQL statements based on JSQLParser.
SaaS Application Platform: druid-multi-tenant-starter is especially suitable for SaaS platforms that need to support multiple tenants. It can ensure the data security and isolation of different tenants and prevent data crossover and leakage.
Enterprise-level System: For enterprises that need to manage data of multiple business units or subsidiaries in the same system, druid-multi-tenant-starter provides an ideal solution, simplifying data management and maintenance work.
Data Sharing Platform: In scenarios where multi-party data sharing is required while data isolation needs to be ensured, druid-multi-tenant-starter can effectively support the management needs of different data sources.
table name
to ignore the addition of the SQL statement for the tenantId field condition.alias
to ignore the addition of the SQL statement for the tenantId field condition.Mybatis
.<dependency> <groupId>io.github.osinn</groupId> <artifactId>druid-multi-tenant-starter</artifactId> <version>1.4.7</version></dependency>
-- Basic configurationmybatis: tenant: config:# Whether to enable the multi-tenant pluginenable: true# The column name of the tenant ID in the databasetenant-id-column: tenant_id
/** * Demonstration: Provide the multi-tenant ID service interface * * @author wency_cai */@Servicepublic class TenantServiceImpl implements ITenantService<Integer>{ @Override public List<Integer> getTenantIds() { // Query the multi-tenant id in the system. If there are multiple, return multiple values. int tenantId = 1; return Lists.newArrayList(tenantId); }}
The druid-multi-tenant-starter has been running normally in the production environment for more than two years since its release. It not only simplifies the development work in a multi-tenant environment but also improves the performance and security of the system. We expect this plugin to help more developers and enterprises manage their multi-tenant systems efficiently and achieve rapid business development and success.
Project address: Click