MyBatis-Mate: Advanced Features and Usage Guide for MyBatis-Plus in Java Backend Development

This article introduces MyBatis-Mate, an official MyBatis-Plus extension that offers enterprise‑grade capabilities such as dictionary binding, field encryption, data masking, dynamic DDL generation, multi‑datasource sharding, data‑scope filtering, and SQL performance logging, complete with Maven dependency setup and code examples.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
MyBatis-Mate: Advanced Features and Usage Guide for MyBatis-Plus in Java Backend Development

MyBatis-Mate is an official extension for MyBatis‑Plus that provides enterprise‑grade features such as dictionary binding, field encryption, data masking, dynamic DDL generation, multi‑datasource sharding, data‑scope filtering and SQL performance logging.

To use it, add the starter dependency:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-mate-starter</artifactId>
    <version>1.0.8</version>
</dependency>

Key capabilities include:

Dictionary binding with @FieldDict to map code values to text.

Field encryption via @FieldEncrypt (e.g., PBEWithMD5AndDES).

Data masking using @FieldSensitive with built‑in SensitiveType strategies.

Automatic DDL maintenance through IDdl implementations for MySQL and PostgreSQL.

Dynamic multi‑datasource sharding and master‑slave switching using @Sharding and custom strategies.

Distributed transaction logging with a configurable PerformanceInterceptor.

Data‑scope filtering via @DataScope and a custom IDataScopeProvider.

Example of a mapper using dictionary binding and encryption:

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @FieldDict(type = "user_sex", target = "sexText")
    @FieldEncrypt(algorithm = Algorithm.PBEWithMD5AndDES)
    User selectById(Long id);
}

Configuration in application.yml can enable health checks, primary datasource selection and define datasource groups for sharding.

Overall, MyBatis‑Mate streamlines backend development by reducing boilerplate and providing ready‑to‑use data handling utilities.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLMyBatisORMDataEncryption
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.