创建MyBatis-Plus版的后端查询项目

发布于:2025-08-09 ⋅ 阅读:(15) ⋅ 点赞:(0)

记得编码和maven库的检测!!!

1、maven库导入包

		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>3.0.5</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
            <version>3.5.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-jsqlparser -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-jsqlparser</artifactId>
            <version>3.5.12</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2、配置文件

spring:
  application:
    name: crm2026

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/demo02?characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true

mybatis-plus:
  configuration:
    log-prefix: mybatis.
    log-impl: org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl
    map-underscore-to-camel-case: true
    lazy-loading-enabled: true
  type-aliases-package: com.situ.crm2026.model
  mapper-locations: classpath*:/mapper/**/*.xml

server:
  port: 8080

logging:
  level:
    mybatis: debug

3、必要类

1、实体类
在这里插入图片描述
2、创建时间那、创建者啊,这些不变的数据单独封装
在这里插入图片描述
3、较为简单的 响应 封装类
在这里插入图片描述
4、后端传来时间范围时,用这个接受处理,而且继承了基础实体类
在这里插入图片描述

4、逻辑方面

1、dao层
在这里插入图片描述
在这里插入图片描述
要想成功分页,还需对分页功能进行配置
在这里插入图片描述

2、Service接口
在这里插入图片描述
在这里插入图片描述

3、api接口层
在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到