Skip to content

Commit 58455c9

Browse files
committed
新增文档
1 parent 1682361 commit 58455c9

6 files changed

Lines changed: 217 additions & 3 deletions

File tree

src/config/sponsors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"title": "CRMEB",
1818
"subtitle": "Java 营销电商系统",
19-
"description": "赋能开发者,让商城开发事半功倍",
19+
"description": "真开源,敢免费商用!源码全开放,二开不用愁!",
2020
"logo": "/images/sponsors/crmeb.webp",
2121
"link": "https://github.crmeb.net/u/MyBatis-Plus"
2222
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: GraalVM Native
3+
sidebar:
4+
order: 18.5
5+
---
6+
7+
MyBatis-Plus adds support for GraalVM Native Image, allowing eligible projects to build native executables with faster startup and lower runtime memory usage.
8+
9+
## Feature Overview
10+
11+
- **Native Image build**: Works with GraalVM Native Image to compile an application into a platform-specific native executable.
12+
- **Spring AOT integration**: In Spring Boot 3 AOT scenarios, framework runtime hints such as reflection and resource access can be registered during build analysis.
13+
- **Simplified deployment**: The generated artifact can run directly without the full JVM startup flow, making it suitable for cloud native, Serverless, container, and startup-sensitive workloads.
14+
15+
## Prerequisites
16+
17+
- Use a JDK that supports Native Image, such as GraalVM JDK.
18+
- The project uses Spring Boot 3.x or another build system that supports GraalVM Native Image.
19+
- The MyBatis-Plus version includes GraalVM Native Image support.
20+
21+
:::note
22+
23+
Native Image performs closed-world analysis at build time. Custom reflection, dynamic proxies, resource files, Mapper XML files, serialization types, and similar project-specific code may still need extra configuration if they are outside the framework's automatic registration scope.
24+
25+
:::
26+
27+
## Build Example
28+
29+
For Maven projects, use Spring Boot Native Build Tools:
30+
31+
```bash
32+
mvn -Pnative native:compile
33+
```
34+
35+
After a successful build, run the generated native executable directly:
36+
37+
```bash
38+
./target/demo
39+
```
40+
41+
To build a container image, use the Spring Boot plugin:
42+
43+
```bash
44+
mvn -Pnative spring-boot:build-image
45+
```
46+
47+
## Notes
48+
49+
- Native image builds usually take much longer than regular JVM Jar builds. Consider configuring a separate CI build task.
50+
- Dynamic SQL, XML Mapper files, custom TypeHandlers, and custom interceptors can still be used, but make sure the related classes and resources can be analyzed by AOT or explicitly registered.
51+
- Native executables are tied to the target operating system and CPU architecture, so build them in a matching environment.
52+
- During development, JVM mode is still recommended for debugging. Run Native Image builds as part of release verification.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: GraalVM Native
3+
sidebar:
4+
order: 18.5
5+
---
6+
7+
MyBatis-Plus 新增支持 `GraalVM Native Image`,可在符合条件的项目中构建原生可执行文件,从而获得更快的启动速度和更低的运行时内存占用。
8+
9+
## 功能概述
10+
11+
- **原生镜像构建**:支持配合 `GraalVM Native Image` 将应用编译为平台相关的原生可执行文件。
12+
- **Spring AOT 适配**:在 `Spring Boot 3 AOT` 场景下,配合框架完成运行期所需的反射、资源等提示信息注册。
13+
- **部署形态简化**:构建产物可直接运行,不再依赖完整 `JVM` 启动流程,适合云原生、`Serverless`、容器镜像等启动敏感场景。
14+
15+
## 使用前提
16+
17+
- 使用支持 `Native Image``JDK`,例如 [GraalVM JDK](https://www.graalvm.org/downloads)
18+
- 项目已接入 `Spring Boot 3.x` 或其他支持 `GraalVM Native Image` 的构建体系。
19+
- MyBatis-Plus 版本需包含 `GraalVM Native Image` 支持。
20+
21+
:::note
22+
23+
Native Image 会在构建期封闭分析应用代码。项目中的自定义反射、动态代理、资源文件、Mapper XML、序列化类型等,如果不属于框架自动注册范围,仍需按 GraalVM 或 Spring AOT 规范补充配置。
24+
25+
:::
26+
27+
## 构建示例
28+
29+
示例工程 `mybatis-plus-native-image-demo`
30+
31+
- [国内 Gitee 下载](https://gitee.com/baomidou/mybatis-plus-native-image-demo)
32+
- [国外 Github 下载](https://gitee.com/baomidou/mybatis-plus-native-image-demo)
33+
34+
[Maven](https://maven.apache.org/download.cgi) 项目可使用 Spring Boot Native Build Tools 构建:
35+
36+
```bash
37+
mvn -Pnative native:compile
38+
```
39+
40+
构建成功后,可直接运行生成的原生可执行文件:
41+
42+
```bash
43+
./target/demo
44+
```
45+
46+
如果使用容器镜像构建,可以通过 Spring Boot 插件生成 Native Image 镜像:
47+
48+
```bash
49+
mvn -Pnative spring-boot:build-image
50+
```
51+
52+
## 注意事项
53+
54+
- 原生镜像构建时间通常明显长于普通 JVM Jar 构建,建议在 CI 环境中单独配置构建任务。
55+
- 动态 SQL、XML Mapper、自定义 TypeHandler、自定义拦截器等扩展能力可以继续使用,但需要确认相关类和资源能被 AOT 分析或显式注册。
56+
- 原生可执行文件与目标操作系统和 CPU 架构相关,需要在匹配的构建环境中产出对应平台的可执行文件。
57+
- 开发阶段仍建议优先使用普通 JVM 模式调试,发布阶段再执行 Native Image 构建验证。

src/content/docs/guides/new-code-generator.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ protected static List<String> getTables(String tables) {
182182

183183
如果您需要更多例子可查看 test 包下面的 samples。
184184

185-
- [H2CodeGeneratorTest](https://github.com/baomidou/generator/blob/develop/mybatis-plus-generator/src/test/java/com/baomidou/mybatisplus/generator/samples/H2CodeGeneratorTest.java)
186-
- [FastAutoGeneratorTest](https://github.com/baomidou/generator/blob/develop/mybatis-plus-generator/src/test/java/com/baomidou/mybatisplus/generator/samples/FastAutoGeneratorTest.java)
185+
- [FastAutoGeneratorTest 更多案例](https://github.com/baomidou/mybatis-plus/tree/3.0/mybatis-plus-generator/src/test/java/com/baomidou/mybatisplus/generator/samples)
186+
- [TableField 元数据扩展处理](https://github.com/baomidou/generator/blob/develop/mybatis-plus-generator/src/test/java/com/baomidou/mybatisplus/generator/samples/FastAutoGeneratorTest.java)
187187

188188
## 配置
189189

src/content/docs/guides/wrapper.mdx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,59 @@ lambdaQueryWrapper.eq(User::getName, "老王");
191191
SELECT * FROM user WHERE name = '老王'
192192
```
193193

194+
### eqOrIsNull <Badge text="Since 3.5.17" type="error"/>
195+
196+
`eqOrIsNull` 相当于 `eq + is null` 等于 = ,值为 null 时自动转为 IS NULL。
197+
198+
#### 使用范围
199+
200+
- `QueryWrapper`
201+
- `LambdaQueryWrapper`
202+
- `UpdateWrapper`
203+
- `LambdaUpdateWrapper`
204+
205+
#### 方法签名
206+
207+
```java
208+
// 设置指定字段的相等条件
209+
eqOrIsNull(R column, Object val)
210+
211+
// 根据条件设置指定字段的相等条件
212+
eqOrIsNull(boolean condition, R column, Object val)
213+
```
214+
215+
#### 参数说明
216+
217+
- `column`:数据库字段名或使用 `Lambda` 表达式的字段名。
218+
- `val`:与字段名对应的值。
219+
- `condition`:一个布尔值,用于控制是否应用这个相等条件。
220+
221+
#### 示例
222+
223+
**普通 Wrapper (`QueryWrapper`)**
224+
225+
```java
226+
QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
227+
queryWrapper.eqOrIsNull("name", "可乐饼干");
228+
```
229+
230+
**Lambda Wrapper (`LambdaQueryWrapper`)**
231+
232+
```java
233+
LambdaQueryWrapper<Product> lambdaQueryWrapper = new LambdaQueryWrapper<>();
234+
lambdaQueryWrapper.eqOrIsNull(Product::getName, null);
235+
```
236+
237+
**生成的 SQL**
238+
239+
```sql
240+
-- 普通 Wrapper
241+
SELECT * FROM product WHERE name = '可乐饼干'
242+
243+
-- Lambda Wrapper
244+
SELECT * FROM product WHERE name is null
245+
```
246+
194247
### ne
195248

196249
`ne` 方法是 MyBatis-Plus 中用于构建查询条件的基本方法之一,它用于设置单个字段的不相等条件。
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: GraalVM Native
3+
sidebar:
4+
order: 18.5
5+
---
6+
7+
MyBatis-Plus は GraalVM Native Image をサポートし、条件を満たすプロジェクトで起動が速く、実行時メモリ使用量の少ないネイティブ実行ファイルを構築できます。
8+
9+
## 機能概要
10+
11+
- **Native Image ビルド**: GraalVM Native Image と連携し、アプリケーションをプラットフォーム固有のネイティブ実行ファイルへコンパイルできます。
12+
- **Spring AOT 連携**: Spring Boot 3 AOT のシナリオで、実行時に必要なリフレクションやリソースアクセスなどのヒント登録と連携します。
13+
- **デプロイ形態の簡素化**: 生成物は完全な JVM 起動フローを経ずに直接実行でき、クラウドネイティブ、Serverless、コンテナ、起動時間が重要な場面に適しています。
14+
15+
## 前提条件
16+
17+
- GraalVM JDK など、Native Image をサポートする JDK を使用します。
18+
- プロジェクトが Spring Boot 3.x、または GraalVM Native Image に対応したビルド体系を使用していること。
19+
- MyBatis-Plus のバージョンが GraalVM Native Image サポートを含んでいること。
20+
21+
:::note
22+
23+
Native Image はビルド時にクローズドワールド分析を行います。カスタムリフレクション、動的プロキシ、リソースファイル、Mapper XML、シリアライズ対象型など、フレームワークの自動登録範囲外にある内容は、GraalVM または Spring AOT の仕様に従って追加設定が必要になる場合があります。
24+
25+
:::
26+
27+
## ビルド例
28+
29+
Maven プロジェクトでは Spring Boot Native Build Tools を使用できます。
30+
31+
```bash
32+
mvn -Pnative native:compile
33+
```
34+
35+
ビルド成功後、生成されたネイティブ実行ファイルを直接起動できます。
36+
37+
```bash
38+
./target/demo
39+
```
40+
41+
コンテナイメージを構築する場合は、Spring Boot プラグインを使用できます。
42+
43+
```bash
44+
mvn -Pnative spring-boot:build-image
45+
```
46+
47+
## 注意事項
48+
49+
- ネイティブイメージのビルド時間は通常の JVM Jar ビルドより長くなるため、CI では個別のビルドタスクとして設定することを推奨します。
50+
- 動的 SQL、XML Mapper、カスタム TypeHandler、カスタムインターセプターなどは引き続き使用できますが、関連するクラスやリソースが AOT 分析対象になるか、明示的に登録されていることを確認してください。
51+
- ネイティブ実行ファイルは対象 OS と CPU アーキテクチャに依存するため、対応する環境でビルドしてください。
52+
- 開発時のデバッグには通常の JVM モードを使い、リリース検証で Native Image ビルドを実行することを推奨します。

0 commit comments

Comments
 (0)