mybatis-plus-sample-quickstart 实践调试

Mybatisplus--Demo 
调试工具:
IntelliJ  IDEA 2019.3.3(Utimate Edition)
数据库
MySQL:8.0.2
Navicat:15.0.17(32-bit)
  • mybatis-plus-sample-quickstart: 快速开始示例
在实践中遇到的问题:

具体可以参照这个

https://www.cnblogs.com/MessiXiaoMo3334/p/13237247.html文章;

具体实践操作:
pom.xml 文件;
插入代码:
 

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>mybatis-plus-samples</artifactId>
        <groupId>com.baomidou</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>mybatis-plus-sample-quickstart</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </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>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

配置数据库

application.yml


# server config
server:
  port: 8999
  #address: 192.168.90.15

# DataSource Config
spring:
  #datasource:
  #driver-class-name: org.h2.Driver
  #schema: classpath:db/schema-h2.sql
  #data: classpath:db/data-h2.sql
  #url: jdbc:h2:mem:test
  #username: root
  #password: 123456
  datasource:
      #url: jdbc:mysql://localhost:3306/demo?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8

      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8
      # url: jdbc:mysql://localhost:3306/demo?serverTimezone=UTC
      username: root
      password: 123456

# Logger Config
logging:
  level:
    com.baomidou.mybatisplus.samples.quickstart: debug

数据库创建表:

创建user表:
DROP TABLE IF EXISTS user;

CREATE TABLE user
(
   id BIGINT(20) NOT NULL COMMENT '主键ID',
   name VARCHAR(30) NULL DEFAULT NULL COMMENT '姓名',
   age INT(11) NULL DEFAULT NULL COMMENT '年龄',
   email VARCHAR(50) NULL DEFAULT NULL COMMENT '邮箱',
   PRIMARY KEY (id)
);
DELETE FROM user;
插入数据:
INSERT INTO user (id, name, age, email) VALUES
(1, 'Jone', 18, 'test1@baomidou.com'),
(2, 'Jack', 20, 'test2@baomidou.com'),
(3, 'Tom', 28, 'test3@baomidou.com'),
(4, 'Sandy', 21, 'test4@baomidou.com'),
(5, 'Billie1', 24, 'test5@baomidou.com'),
(6, 'Billie6', 16, 'test6@baomidou.com');




 

调试Test代码:直接测试;
 

 

可以写一个control,来调试mybatis-plus调用sql;

输入结果:


https://github.com/baomidou/mybatis-plus-samples


有Mybatis-plus的Demo实例代码。

参考问题:

https://blog.csdn.net/Tranne/article/details/109599997

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值