Secure Your Data with MyBatis‑Plus 3.3.2: New Encryption Features Explained
Version 3.3.2 of MyBatis‑Plus introduces elegant data‑security measures, including YML‑based encrypted configuration, AES key generation, and encrypted database credentials, while also delivering numerous bug fixes and enhancements such as pagination improvements, generator updates, and support for additional databases.
MyBatis‑Plus 3.3.2 Released – New Elegant Data‑Security Measures
What is MyBatis‑Plus
MyBatis‑Plus (MP) is an enhancement tool for MyBatis that adds features without changing the core, aiming to simplify development and improve efficiency.
Our vision is to become the best partner for MyBatis, like the 1P/2P duo in Contra, doubling efficiency.
Configuring Security
Data‑security protection aims to safeguard database configuration and data, limiting the risk of sensitive information leakage caused by developer turnover.
YML configuration:
// Encryption configuration: mpw: prefix followed by encrypted content (not limited to DB config)
spring:
datasource:
url: mpw:qRhvCwF4GOqjessEB3G+a5okP+uXXr96wcucn2Pev6BfaoEMZ1gVpPPhdDmjQqoM
password: mpw:Hzy5iliJbwDHhjLs1L0j6w==
username: mpw:Xb+EgsyuYRXw7U7sBJjBpA==Key Encryption
// Generate a 16‑byte random AES key
String randomKey = AES.generateRandomKey();
// Encrypt with random key
String result = AES.encrypt(data, randomKey);
// Usage as Jar startup parameter (IDEA Program arguments)
--mpw.key=d1104d7c2b606f0bNote!
Encrypted configuration must start with the mpw: prefix. Keep the random key securely; the fewer people who know it, the better.
Changelog
Pagination parameter extraction, unit test fixes
Support for DM and Microsoft database code‑generator table filtering
Fix code‑generator property field rule errors
SelectById now supports custom method names
Fix pagination plugin database type detection
JSON converter null‑value handling
Add AES encryption for DB username and password
Improve generic method parameters support
In the next article we will share the design and implementation of configuration file encryption and decryption.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
