diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MyBatisFlexInitializer.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MyBatisFlexInitializer.java new file mode 100644 index 00000000..f458eaca --- /dev/null +++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MyBatisFlexInitializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.mybatisflex.spring.boot;
+
+/**
+ * MyBatisFlex 初始化监听器
+ * 一般可以用于去初始化:
+ *
+ * 1、自定义主键生成器
+ * 2、FlexGlobalConfig 的全局配置
+ * 3、多租户配置
+ * 4、动态表名配置
+ * 5、逻辑删除处理器配置
+ * 6、自定义脱敏规则
+ * 7、SQL 审计配置
+ * 8、SQL 打印配置
+ * 9、数据源解密器配置
+ * 10、自定义数据方言配置
+ * ...
+ */
+public interface MyBatisFlexInitializer {
+ void onInitBefore();
+}
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAutoConfiguration.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAutoConfiguration.java
index b4b81f69..6c99fda0 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAutoConfiguration.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAutoConfiguration.java
@@ -121,6 +121,9 @@ public class MybatisFlexAutoConfiguration implements InitializingBean {
//多租户
protected final TenantFactory tenantFactory;
+ //初始化监听
+ protected final MyBatisFlexInitializer myBatisFlexInitializer;
+
public MybatisFlexAutoConfiguration(MybatisFlexProperties properties, ObjectProvider