springboot 整合 mybatis 看了忘不了
( springboot 不管整合啥,记住三大步: 1、引入依赖 2、配置 3、使用 )
首先是引入依赖(很长):(里面有 逆向工程得插件和依赖(已经有标注) 可以不用理会,直接删除或留着都不碍事)
最好自己直接用 idea 建个 springboot 项目,把 mybatis 也选中,因为自己组合很容易出现 XXXX ,算了,自己经历吧,
还是自己凑吧,别直接建,错几次,错到你气急败坏,这样记得清楚
<?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.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.tt</groupId>
<artifactId>mybatis-generator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mybatis-generator</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--springboot 开始-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!--mybatis 开始-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!-- mysql 开始-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot