一、application.properties
mybatis.mapper-locations=classpath:mapper/*.xml
spring.datasource.url=jdbc:mysql://localhost:3306/mybatis
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
二、pom.xml
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>```
## 三、mapper接口
```java
/**
* Copyright (c) 2020 ucsmy.com, All rights reserved.
*/
package com.example.springbootweb.mapper;
import com.example.springbootweb.entity.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Description:
* @Author: Administrator
* @Created Date: 2020年02月09日
* @LastModifyDate:
* @LastModifyBy:
* @Version:
*/
@Mapper
public interface UserMapper
{
List<User> selectAllUser();
}
四、mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
< mapper namespace = " com.example.springbootweb.mapper.UserMapper" >
< select id = " selectAllUser" resultType = " map" >
SELECT * from USER
</ select>
</ mapper> ```