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

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

1、maven库导入包

xml 复制代码
		<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、配置文件

yaml 复制代码
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接口层

相关推荐
fengxin_rou3 小时前
[Redis从零到精通|第四篇]:缓存穿透、雪崩、击穿
java·redis·缓存·mybatis·idea·多线程
老毛肚13 小时前
MyBatis插件原理及Spring集成
java·spring·mybatis
马尔代夫哈哈哈18 小时前
MyBatis 入门与实战:从配置到CRUD一站式指南
mybatis
Jul1en_19 小时前
【MyBatis/plus】核心配置、插件与 MyBatis-Plus 构造器 Wrapper
mybatis
LiZhen79821 小时前
SpringBoot 实现动态切换数据源
java·spring boot·mybatis
我是Superman丶1 天前
在 PostgreSQL 中使用 JSONB 类型并结合 MyBatis-Plus 实现自动注入,主要有以下几种方案
数据库·postgresql·mybatis
Pluto_CSND1 天前
基于mybatis-generator插件生成指定数据表的实体类、xml文件和dao层接口
mybatis
indexsunny1 天前
互联网大厂Java面试实战:微服务与Spring生态技术解析
java·spring boot·redis·kafka·mybatis·hibernate·microservices
手握风云-1 天前
JavaEE 进阶第十六期:MyBatis,查询请求的生命周期全景图(一)
java·java-ee·mybatis
独断万古他化1 天前
【SSM开发实战:博客系统】(二)JWT 登录流程、拦截器实现和用户信息接口落地
spring boot·spring·mybatis·博客系统·项目