项目结构
├─src
 │ ├─main
 │ │ ├─java
 │ │ │ └─com
 │ │ │ └─wml
 │ │ │ └─learn
 │ │ │ ├─controller
 │ │ │ ├─domain
 │ │ │ │ └─po
 │ │ │ ├─mapper
 │ │ │ ├─service
 │ │ │ │ └─serviceImpl
 │ │ │ └─utils
 │ │ │ └─core
 │ │ └─resources
 │ │ └─templates
 │ └─test
 │ └─java
 │ └─com
 │ └─wml
 │ └─learn
Controller
// UserController
package com.wml.learn.controller;
import com.wml.learn.domain.po.User;
import com.wml.learn.service.UserService;
import com.wml.learn.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/user")
@Api(tags = "用户控制类", value = "用户控制类")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("list")
    @ApiOperation(value = "查询所有用户")
    public AjaxResult list() {
        List<User> list = userService.list();
        return AjaxResult.success(list);
    }
}Domain
// User
package com.wml.learn.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("user")
@ToString
public class User extends Model<User> {
    @TableId(value="AUTO_ID", type = IdType.AUTO)
    private Integer autoId;
    private String userName;
    private String password;
}Mapper
// UserMapper
package com.wml.learn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wml.learn.domain.po.User;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserMapper extends BaseMapper<User> {
}Service
// UserService
package com.wml.learn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wml.learn.domain.po.User;
public interface UserService extends IService<User> {
}ServiceImpl
// UserServiceImpl
package com.wml.learn.service.serviceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wml.learn.domain.po.User;
import com.wml.learn.mapper.UserMapper;
import com.wml.learn.service.UserService;
import org.springframework.stereotype.Service;
@Service("UserService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}启动类
package com.wml.learn;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@MapperScan({"com.wml.learn.mapper"})
public class LearnApplication {
    public static void main(String[] args) {
        System.out.println("*******开始启动*******");
        SpringApplication.run(LearnApplication.class, args);
        System.out.println("*******成功启动*******");
    }
}Pom文件
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.wml</groupId>
    <artifactId>learn</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>learn</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- jdbc驱动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.mybatis.spring.boot</groupId>-->
<!--            <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!--            <version>1.3.1</version>-->
<!--        </dependency>-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3.1</version>
        </dependency>
        <!-- mysql驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.20</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.70</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>                










