File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,9 @@ static {
142
142
## 设置 SQL 解析线程池
143
143
144
144
自3.5.6开始,对JSQLParser(4.9) 支持了线程池解析复用,可减少重复创建线程池带来的性能开销。
145
+
145
146
默认创建固定线程池核心数: (Runtime.getRuntime().availableProcessors() + 1) / 2
147
+
146
148
如果默认的线程池方式不太符合你实际部署情况,请用下面的方式指定你的自定义线程池,自行创建的线程池需要注意自行关闭。
147
149
``` java
148
150
static {
@@ -152,4 +154,27 @@ static {
152
154
JsqlParserGlobal . setExecutorService(.... );
153
155
}
154
156
```
157
+
158
+ ## 设置 JsqlParser解析处理方法
159
+ 如果需要JsqlParser的sql语句进行加工处理,请通过下面的方式进行指定,处理完成 sql 字符串再交由解析器进行解析。
160
+ ``` java
161
+ /*
162
+ 3.5.6~3.5.11 请使用 JsqlParserGlobal.executorService
163
+ 3.5.11+: JsqlParserGlobal.getExecutorService()
164
+ 低于3.5.6的版本只能使用
165
+ CCJSqlParserUtil.parseStatements(sql);
166
+ CCJSqlParserUtil.parse(sql)
167
+ **/
168
+ static {
169
+ JsqlParserGlobal . setParserMultiFunc((sql)- > {
170
+ System . out. println(" 解析SQL:" + sql);
171
+ return CCJSqlParserUtil . parseStatements(sql, JsqlParserGlobal . getExecutorService(), null );
172
+ });
173
+ JsqlParserGlobal . setParserSingleFunc((sql)- > {
174
+ System . out. println(" 解析SQL:" + sql);
175
+ return CCJSqlParserUtil . parse(sql, JsqlParserGlobal . getExecutorService(), null );
176
+ });
177
+ }
178
+ ```
179
+
155
180
以上是 MyBatis-Plus 插件主体的详细介绍和使用方法。通过这些插件,你可以大大增强 MyBatis 的功能,提高开发效率。
You can’t perform that action at this time.
0 commit comments