Mybatis-plus
Mybatis-plus不是官方的,而是别人扩展的
官网
而且是有中国人开发的,所以文档什么很容易看,下面的内容都可以查看官网,有更详细的解答。
(在个人练习中,version也就是乐观锁那一块起不了效果,如果以后解决了再回来更改)
环境配置
因为mybatis-plus是数据库的操作,所以我们需要先配置以下mysql的环境:
CREATE TABLE USER(
id INT NOT NULL,
NAME VARCHAR(20) DEFAULT NULL
)
然后就是往里面添加一些数据。
然后结合Springboot一起使用,所以引入springboot web场景。
pom.xml环境配置
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3</version>
</dependency>
<!--springboot web环境-->
<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>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>