springboot+mybatisplus实现基本的增删改查以及分页查询。这里使用的是Restful风格包括简单描述Restful是什么

    先实现springboot+mybatisplus的增删改查接口使用postman测试:
第一步创建项目导入依赖:
直接给大家了:
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.6.6
    
    com.okchan
    springboot_07_ssmp
    0.0.1-SNAPSHOT
    
        1.8
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            mysql
            mysql-connector-java
            runtime
        
        
            com.baomidou
            mybatis-plus-boot-starter
            3.4.3.4
        
        
            com.alibaba
            druid-spring-boot-starter
            1.2.6
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    
然后用yml配置,修改端口(也可以不做)。
然后给一下SQL:
Drop TABLE  if exists tb_book;
CREATE TABLE tb_book (
    `id` INT(10) NOT NULL AUTO_INCREMENT,
        `type` VARCHAR(20),
        `name` VARCHAR(50),
        `description` VARCHAR(255),
        PRIMARY KEY(`id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
INSERT INTO  `tb_book` (type,name,description)
VALUES ('计算机相关','springboot','入门' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('计算机相关','spring','入门到放弃' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('计算机相关','java核心技术','入门到精通' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('计算机相关','mysql','入门到精通' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('市场营销','市场营销书3','入门' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('市场营销','市场营销书2','入门' );
INSERT INTO  `tb_book` (type,name,description)
VALUES ('市场营销','市场营销书1','入门' );
然后导入lombok简化代码开发。(也可以直接写对应的get,set,toString方法都可以看个人喜好)
    org.projectlombok
    lombok
    1.18.20
    provided
pom文件配置:
server:
  port: 80
spring:
  datasource:
    druid:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC
      username: root
      password: 123456
#id-type: auto 设置为数据库的id自增策略
mybatis-plus:
  global-config:
    db-config:
      table-prefix: tb_
      id-type: auto

你可能感兴趣的:(spring,boot,java)