之前搭建了@Select标签来做SringBoot+Mybatis的集成。这次使用@SelectProvider标签的方式搭建一次。
一、搭建SpringBoot的项目
https://start.spring.io/自己配置SpringBoot的项目,点击“Generate Project”按钮就可以下载下来一个配置好的SpringBoot项目。
二、项目结构
三、项目代码
demo代码实现的是对表数据的一个简单查询。
1、pom中的mave配置
org.springframework.boot
spring-boot-starter-jdbc
org.springframework.boot
spring-boot-starter-web
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.2
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-test
test
2、Controller
package com.example.demo.Controller;
import com.example.demo.Service.TeacherService;
import com.example.demo.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.s