소스 검색

项目集成MyBatis-Flex-------0

Gaokun Wang 5 달 전
부모
커밋
e54b4505b1

+ 8 - 0
eco-auth/eco-auth-biz/pom.xml

@@ -20,5 +20,13 @@
             <artifactId>eco-auth-api</artifactId>
             <version>${revision}</version>
         </dependency>
+        <dependency>
+            <groupId>org.eco.vip</groupId>
+            <artifactId>com-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eco.vip</groupId>
+            <artifactId>com-orm</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 36 - 0
eco-auth/eco-auth-biz/src/main/java/org/eco/vip/auth/controller/user/UserController.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.auth.controller.user;
+
+
+import jakarta.annotation.Resource;
+import org.eco.vip.auth.domain.user.User;
+import org.eco.vip.auth.service.user.IUserService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @description UserController
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 22:24
+ */
+@RestController
+@RequestMapping("/system/user")
+public class UserController {
+
+    @Resource
+    private IUserService userService;
+
+    @GetMapping("/list")
+    public List<User> list() {
+        return userService.getUsers();
+    }
+
+}

+ 100 - 0
eco-auth/eco-auth-biz/src/main/java/org/eco/vip/auth/domain/user/User.java

@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.auth.domain.user;
+
+
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.eco.vip.orm.domain.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * @description User
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 23:12
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Table(value = "sys_user")
+public class User extends BaseEntity {
+
+    /**
+     * 用户ID
+     */
+    @Id
+    private Long userId;
+
+    /**
+     * 部门ID
+     */
+    private Long deptId;
+
+    /**
+     * 用户账号
+     */
+    private String userName;
+
+    /**
+     * 用户昵称
+     */
+    private String nickName;
+
+    /**
+     * 用户登录设备类型(sys_user系统用户、app_user App用户)
+     */
+    private String userType;
+
+    /**
+     * 用户邮箱
+     */
+    private String email;
+
+    /**
+     * 手机号码
+     */
+    private String phonenumber;
+
+    /**
+     * 用户性别
+     */
+    private String gender;
+
+    /**
+     * 用户头像
+     */
+    private Long avatar;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 帐号状态(1正常 0停用)
+     */
+    private String status;
+
+    /**
+     * 删除标志(1代表已删除 0代表存在)
+     */
+    private Integer delFlag;
+
+    /**
+     * 最后登录IP
+     */
+    private String loginIp;
+
+    /**
+     * 最后登录时间
+     */
+    private Date loginDate;
+}

+ 21 - 0
eco-auth/eco-auth-biz/src/main/java/org/eco/vip/auth/mapper/UserMapper.java

@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.auth.mapper;
+
+
+import com.mybatisflex.core.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.eco.vip.auth.domain.user.User;
+
+/**
+ * @description UserMapper
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 23:25
+ */
+@Mapper
+public interface UserMapper extends BaseMapper<User> {
+}

+ 22 - 0
eco-auth/eco-auth-biz/src/main/java/org/eco/vip/auth/service/user/IUserService.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.auth.service.user;
+
+
+import com.mybatisflex.core.service.IService;
+import org.eco.vip.auth.domain.user.User;
+
+import java.util.List;
+
+/**
+ * @description IUserService
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 23:20
+ */
+public interface IUserService extends IService<User> {
+    List<User> getUsers();
+}

+ 28 - 0
eco-auth/eco-auth-biz/src/main/java/org/eco/vip/auth/service/user/UserService.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.auth.service.user;
+
+
+import com.mybatisflex.spring.service.impl.ServiceImpl;
+import org.eco.vip.auth.domain.user.User;
+import org.eco.vip.auth.mapper.UserMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @description UserService
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 23:20
+ */
+@Service
+public class UserService extends ServiceImpl<UserMapper, User> implements IUserService {
+    @Override
+    public List<User> getUsers() {
+        return this.list();
+    }
+}

+ 42 - 5
eco-bom/pom.xml

@@ -18,12 +18,12 @@
         <spring-boot.version>3.4.3</spring-boot.version>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <maven.compiler.target>${java.version}</maven.compiler.target>
-        <!-- 插件版本 -->
-        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
-        <maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
-        <flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
-        <mapstruct.version>1.6.3</mapstruct.version>
         <lombok.version>1.18.36</lombok.version>
+        <mybatis-flex.version>1.10.8</mybatis-flex.version>
+        <HikariCP.version>6.2.1</HikariCP.version>
+        <hutool-5.version>5.8.36</hutool-5.version>
+        <easy-trans.version>3.0.6</easy-trans.version>
+        <jackson.version>2.18.3</jackson.version>
     </properties>
 
     <!-- 全局的依赖配置-->
@@ -52,12 +52,49 @@
                 <artifactId>com-core</artifactId>
                 <version>${revision}</version>
             </dependency>
+
+            <!-- com-core -->
+            <dependency>
+                <groupId>org.eco.vip</groupId>
+                <artifactId>com-orm</artifactId>
+                <version>${revision}</version>
+            </dependency>
+
             <!-- lombok -->
             <dependency>
                 <groupId>org.projectlombok</groupId>
                 <artifactId>lombok</artifactId>
                 <version>${lombok.version}</version>
             </dependency>
+
+            <!-- mybatis-flex -->
+            <dependency>
+                <groupId>com.mybatis-flex</groupId>
+                <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+                <version>${mybatis-flex.version}</version>
+            </dependency>
+
+            <!-- 数据库连接池-->
+            <dependency>
+                <groupId>com.zaxxer</groupId>
+                <artifactId>HikariCP</artifactId>
+                <version>${HikariCP.version}</version>
+            </dependency>
+
+            <!-- hutool 的依赖配置-->
+            <dependency>
+                <groupId>cn.hutool</groupId>
+                <artifactId>hutool-all</artifactId>
+                <version>${hutool-5.version}</version>
+            </dependency>
+
+            <!-- JSON工具类 -->
+            <dependency>
+                <groupId>com.fasterxml.jackson.core</groupId>
+                <artifactId>jackson-databind</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 </project>

+ 29 - 0
eco-common/com-core/pom.xml

@@ -16,5 +16,34 @@
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+
+        <!-- Mysql驱动包 -->
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+        </dependency>
+
+        <!-- 数据库连接池-->
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+
+        <!-- hutool -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+
+        <!-- JSON工具类 -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 21 - 0
eco-common/com-orm/pom.xml

@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.eco.vip</groupId>
+        <artifactId>eco-common</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <artifactId>com-orm</artifactId>
+    <name>${project.artifactId}</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!-- com-core -->
+        <dependency>
+            <groupId>org.eco.vip</groupId>
+            <artifactId>com-core</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 89 - 0
eco-common/com-orm/src/main/java/org/eco/vip/orm/config/MyBatisFlexConfig.java

@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.orm.config;
+
+
+import com.mybatisflex.core.FlexGlobalConfig;
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.core.audit.ConsoleMessageCollector;
+import com.mybatisflex.core.audit.MessageCollector;
+import com.mybatisflex.core.datasource.DataSourceDecipher;
+import com.mybatisflex.core.mybatis.FlexConfiguration;
+import com.mybatisflex.core.query.QueryColumnBehavior;
+import com.mybatisflex.spring.boot.ConfigurationCustomizer;
+import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.logging.stdout.StdOutImpl;
+import org.eco.vip.orm.decipher.Decipher;
+import org.eco.vip.orm.domain.BaseEntity;
+import org.eco.vip.orm.listener.EntityInsertListener;
+import org.eco.vip.orm.listener.EntityUpdateListener;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * @description mybatis-flex配置
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 19:54
+ */
+@EnableTransactionManagement(proxyTargetClass = true)
+@AutoConfiguration
+@Slf4j
+@Configuration
+public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCustomizer {
+
+    static {
+        QueryColumnBehavior.setIgnoreFunction(QueryColumnBehavior.IGNORE_BLANK);
+        QueryColumnBehavior.setSmartConvertInToEquals(true);
+    }
+
+    @Value("${mybatis-flex.audit_enable}")
+    private Boolean enableAudit = false;
+    @Value("${mybatis-flex.sql_print}")
+    private Boolean sqlPrint = false;
+
+    /**
+     * 数据源解密
+     */
+    @Bean
+    public DataSourceDecipher decipher() {
+        return new Decipher();
+    }
+
+    @Override
+    public void customize(FlexConfiguration configuration) {
+        //mybatis实现的打印详细sql及返回结果到控制台,便于调试
+        if (sqlPrint) {
+            configuration.setLogImpl(StdOutImpl.class);
+        }
+    }
+
+    /**
+     * Mybatis-Flex自定义初始化配置
+     *
+     * @param globalConfig 全局配置
+     */
+    @Override
+    public void customize(FlexGlobalConfig globalConfig) {
+        // 注册全局数据填充监听器
+        globalConfig.registerInsertListener(new EntityInsertListener(), BaseEntity.class);
+        globalConfig.registerUpdateListener(new EntityUpdateListener(), BaseEntity.class);
+
+        // 开启审计功能
+        AuditManager.setAuditEnable(enableAudit);
+        if (sqlPrint) {
+            // 开启sql打印默认会开启sql审计
+            AuditManager.setAuditEnable(true);
+            //设置 SQL 审计收集器
+            MessageCollector collector = new ConsoleMessageCollector();
+            AuditManager.setMessageCollector(collector);
+        }
+    }
+}

+ 28 - 0
eco-common/com-orm/src/main/java/org/eco/vip/orm/decipher/Decipher.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.orm.decipher;
+
+
+import com.mybatisflex.core.datasource.DataSourceDecipher;
+import com.mybatisflex.core.datasource.DataSourceProperty;
+
+/**
+ * @description 数据源解密
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 20:01
+ */
+public class Decipher implements DataSourceDecipher {
+    public String decrypt(DataSourceProperty dataSourceProperty, String value) {
+
+        //解密数据源URL、用户名、密码,通过编码支持任意加密方式的解密
+        String result = "";
+        switch (dataSourceProperty) {
+            case URL, USERNAME, PASSWORD -> result = value;
+        }
+        return result;
+    }
+}

+ 89 - 0
eco-common/com-orm/src/main/java/org/eco/vip/orm/domain/BaseEntity.java

@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.orm.domain;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.mybatisflex.annotation.Column;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @description 全局基础类
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 20:30
+ */
+@Data
+public class BaseEntity implements Serializable {
+
+    /**
+     * 租户编号
+     */
+    @Column(tenantId = true)
+    private Long tenantId;
+
+    /**
+     * 乐观锁
+     */
+    @Column(version = true)
+    private Integer version;
+
+    /**
+     * 搜索值
+     */
+    @JsonIgnore
+    @Column(ignore = true)
+    private String searchValue;
+
+    /**
+     * 创建者
+     */
+    private Long createBy;
+
+    /**
+     * 创建者
+     */
+    @Column(ignore = true)
+    private String createByName;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    private Long updateBy;
+
+    /**
+     * 更新者-姓名
+     */
+    @Column(ignore = true)
+    private String updateByName;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 请求参数
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    @Column(ignore = true)
+    private Map<String, Object> params = new HashMap<>();
+
+}

+ 42 - 0
eco-common/com-orm/src/main/java/org/eco/vip/orm/listener/EntityInsertListener.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.orm.listener;
+
+
+import cn.hutool.core.util.ObjectUtil;
+import com.mybatisflex.annotation.InsertListener;
+import org.eco.vip.orm.domain.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * @description Entity实体类全局插入数据监听器
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 20:03
+ */
+public class EntityInsertListener implements InsertListener {
+    public void onInsert(Object entity) {
+        try {
+            if (ObjectUtil.isNotNull(entity) && (entity instanceof BaseEntity baseEntity)) {
+//                Long loginUserId = LoginHelper.getUserId();
+                Long loginUserId = 1L;
+                Date createTime = ObjectUtil.isNotNull(baseEntity.getCreateTime())
+                        ? baseEntity.getCreateTime() : new Date();
+                if (ObjectUtil.isNull(baseEntity.getCreateBy())) {
+                    baseEntity.setCreateBy(loginUserId);
+                }
+                baseEntity.setCreateTime(createTime);
+                if (ObjectUtil.isNull(baseEntity.getUpdateBy())) {
+                    baseEntity.setUpdateBy(loginUserId);
+                }
+                baseEntity.setUpdateTime(createTime);
+            }
+        } catch (Exception e) {
+//            throw new BusinessException("全局插入数据监听器注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
+        }
+    }
+}

+ 36 - 0
eco-common/com-orm/src/main/java/org/eco/vip/orm/listener/EntityUpdateListener.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2025 GaoKunW
+ *
+ */
+
+package org.eco.vip.orm.listener;
+
+
+import cn.hutool.core.util.ObjectUtil;
+import com.mybatisflex.annotation.UpdateListener;
+import org.eco.vip.orm.domain.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * @description Entity实体类全局更新数据监听器
+ *
+ * @author GaoKunW
+ * @date 2025/3/9 21:17
+ */
+public class EntityUpdateListener implements UpdateListener {
+    @Override
+    public void onUpdate(Object entity) {
+        try {
+            if (ObjectUtil.isNotNull(entity) && (entity instanceof BaseEntity baseEntity)) {
+                Long loginUserId = 1L; //LoginHelper.getUserId()
+                if (ObjectUtil.isNull(baseEntity.getUpdateBy())) {
+                    baseEntity.setUpdateBy(loginUserId);
+                }
+                baseEntity.setUpdateTime(new Date());
+            }
+        } catch (Exception e) {
+//            throw new BusinessException("全局更新数据监听器注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
+        }
+    }
+}

+ 1 - 0
eco-common/com-orm/src/main/resources/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+org.eco.vip.orm.config.MyBatisFlexConfig

+ 1 - 0
eco-common/pom.xml

@@ -15,5 +15,6 @@
     <modules>
         <module>com-web</module>
         <module>com-core</module>
+        <module>com-orm</module>
     </modules>
 </project>

+ 6 - 31
eco-start/pom.xml

@@ -12,9 +12,14 @@
     <description>eco-start web 服务入口</description>
     <packaging>jar</packaging>
     <dependencies>
+<!--        <dependency>-->
+<!--            <groupId>org.eco.vip</groupId>-->
+<!--            <artifactId>com-web</artifactId>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>org.eco.vip</groupId>
-            <artifactId>com-web</artifactId>
+            <artifactId>eco-auth-biz</artifactId>
+            <version>${revision}</version>
         </dependency>
     </dependencies>
 
@@ -31,36 +36,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>15</source>
-                    <target>15</target>
-                </configuration>
-            </plugin>
-            <!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-jar-plugin</artifactId>-->
-<!--                <version>${maven-jar-plugin.version}</version>-->
-<!--            </plugin>-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-war-plugin</artifactId>-->
-<!--                <version>${maven-war-plugin.version}</version>-->
-<!--                <configuration>-->
-<!--                    <failOnMissingWebXml>false</failOnMissingWebXml>-->
-<!--                    <warName>${project.artifactId}</warName>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-compiler-plugin</artifactId>-->
-<!--                <configuration>-->
-<!--                    <source>15</source>-->
-<!--                    <target>15</target>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
         </plugins>
         <finalName>${project.artifactId}</finalName>
     </build>

+ 4 - 1
eco-start/src/main/java/org/eco/vip/StartApplication.java

@@ -40,7 +40,10 @@ public class StartApplication {
                         本地:    http://localhost:{}
                         ----------------------------------------------------------""",
                 env.getProperty("server.port"));
-        System.out.println("启动成功! 🎉🎉🎉🎉🎉");
+        log.info("""
+                StartApplication
+                启动成功! 🎉🎉🎉🎉🎉
+                """);
     }
 
     /**

+ 38 - 0
eco-start/src/main/resources/application-local.yml

@@ -0,0 +1,38 @@
+--- # 数据源配置
+spring:
+  datasource:
+    type: com.zaxxer.hikari.HikariDataSource
+    hikari:
+      # 最大连接池数量
+      maximum-pool-size: 20
+      # 最小空闲线程数量
+      minimum-idle: 10
+      # 配置获取连接等待超时的时间
+      connectionTimeout: 30000
+      # 校验超时时间
+      validationTimeout: 5000
+      # 空闲连接存活最大时间,默认10分钟
+      idleTimeout: 600000
+      # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
+      maxLifetime: 1800000
+      # 多久检查一次连接的活性
+      keepaliveTime: 30000
+mybatis-flex:
+  # sql审计
+  audit_enable: true
+  # sql打印
+  sql_print: true
+  # 数据源
+  datasource:
+    # 数据源1
+    ds1:
+      type: ${spring.datasource.type}
+      driver-class-name: com.mysql.cj.jdbc.Driver
+      url: jdbc:mysql://localhost:3306/eco-boot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
+      username: root
+      password: root123
+    # 数据源2
+#    ds2:
+#      url: jdbc:mysql://127.0.0.1:3306/eco1
+#      username: root
+#      password: root123

+ 44 - 0
eco-start/src/main/resources/application.yml

@@ -11,6 +11,8 @@ eco:
 spring:
   application:
     name: ${eco.name}
+  profiles:
+    active: @profiles.active@
   mvc:
     servlet:
       load-on-startup: 1
@@ -22,3 +24,45 @@ server:
   servlet:
     # 应用的访问路径
     context-path: /
+
+# MyBatisFlex公共配置
+# https://mybatis-flex.com/zh/base/configuration.html
+mybatis-flex:
+  # 搜索指定包别名
+  type-aliases-package: org.eco.vip.**.domain.**
+  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级:com.**.**.mapper
+  mapper-package: org.eco.vip.**.mapper
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  configuration:
+    ## 以下为mybatis原生配置 https://mybatis.org/mybatis-3/zh/configuration.html
+    # 自动驼峰命名规则(camel case)映射
+    map_underscore_to_camel_case: true
+    # MyBatis 自动映射策略
+    # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
+    auto_mapping_behavior: FULL
+    # MyBatis 自动映射时未知列或未知属性处理策
+    # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
+    auto_mapping_unknown_column_behavior: NONE
+    # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
+    # 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
+    # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
+    #log_impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+    cacheEnabled: true
+  global-config:
+    # 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
+    print-banner: false
+    # 全局的 ID 生成策略配置:雪花算法
+    key-config:
+      key-type: Generator
+      value: snowFlakeId
+
+# 日志配置
+logging:
+  level:
+    org.eco.vip: @logging.level@
+    org.springframework: warn
+    com.zaxxer.hikari.pool.HikariPool: ERROR
+    com.zaxxer.hikari.HikariDataSource: ERROR
+    org.mybatis.spring.mapper: error

+ 39 - 0
pom.xml

@@ -24,6 +24,15 @@
         <java.version>21</java.version>
         <lombok.version>1.18.36</lombok.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+        <spring-boot.version>3.4.3</spring-boot.version>
+
+        <!-- 插件版本 -->
+        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
+        <maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
+        <flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
+        <mapstruct.version>1.6.3</mapstruct.version>
+
     </properties>
 
     <!-- 依赖管理 -->
@@ -103,17 +112,24 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${maven-surefire-plugin.version}</version>
                 </plugin>
                 <!-- maven-compiler-plugin 插件,解决 spring-boot-configuration-processor + Lombok + MapStruct 组合 -->
                 <!-- https://stackoverflow.com/questions/33483697/re-run-spring-boot-configuration-annotation-processor-to-update-generated-metada -->
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
+                    <version>${maven-compiler-plugin.version}</version>
                     <configuration>
+                        <release>${java.version}</release>
+                        <source>${java.version}</source>
+                        <target>${java.version}</target>
+                        <encoding>${project.build.sourceEncoding}</encoding>
                         <annotationProcessorPaths>
                             <path>
                                 <groupId>org.springframework.boot</groupId>
                                 <artifactId>spring-boot-configuration-processor</artifactId>
+                                <version>${spring-boot.version}</version>
                             </path>
                             <path>
                                 <groupId>org.projectlombok</groupId>
@@ -124,7 +140,12 @@
                             <path>
                                 <groupId>org.mapstruct</groupId>
                                 <artifactId>mapstruct-processor</artifactId>
+                                <version>${mapstruct.version}</version>
                             </path>
+<!--                            <path>-->
+<!--                                <groupId>com.mybatis-flex</groupId>-->
+<!--                                <artifactId>mybatis-flex-processor</artifactId>-->
+<!--                            </path>-->
                         </annotationProcessorPaths>
                         <!-- 编译参数写在 arg 内,解决 Spring Boot 3.2 的 Parameter Name Discovery 问题 -->
                         <debug>false</debug>
@@ -167,6 +188,24 @@
                 </executions>
             </plugin>
         </plugins>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <!-- 关闭过滤 -->
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <!-- 引入所有 匹配文件进行过滤 -->
+                <includes>
+                    <include>application*</include>
+                    <include>bootstrap*</include>
+                    <include>banner*</include>
+                </includes>
+                <!-- 启用过滤 即该资源中的变量将会被过滤器中的值替换 -->
+                <filtering>true</filtering>
+            </resource>
+        </resources>
     </build>
 
 </project>