From a9a3e1a0570189cc36a3468dbc5e4a1f75350882 Mon Sep 17 00:00:00 2001 From: dataprince Date: Wed, 5 Jul 2023 11:54:28 +0800 Subject: [PATCH] =?UTF-8?q?Mybatis-Flex=E7=BB=9F=E4=B8=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E4=B8=BB=E9=94=AE?= =?UTF-8?q?=E4=B8=BA=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/framework/config/MyBatisConfig.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java index fe239ca..1842903 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java @@ -11,8 +11,9 @@ import com.github.pagehelper.PageInterceptor; /** * Mybatis支持*匹配扫描包 - * - * @author ruoyi + * Mybatis-Flex配置 + * + * @author dataprince数据小王子 */ @Configuration @MapperScan("com.ruoyi.**.mapper") @@ -31,5 +32,11 @@ public class MyBatisConfig // 关闭banner globalConfig.setPrintBanner(false); + //统一设置数据库表主键为雪花算法 + FlexGlobalConfig.KeyConfig keyConfig = new FlexGlobalConfig.KeyConfig(); + keyConfig.setKeyType(KeyType.Generator); + keyConfig.setValue(KeyGenerators.snowFlakeId); + //keyConfig.setBefore(true); + FlexGlobalConfig.getDefaultConfig().setKeyConfig(keyConfig); } } \ No newline at end of file