MyBatis Plus
国产的开源框架,基于MyBatis
核心功能就是简化MyBatis的开发,提高效率。
MyBatis Plus快速上手
1.创建springboot工程
2.导入mybatisplus的依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1.tmp</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.1.tmp</version>
</dependency>
3.创建实体类Users(你自己定一个比较简单的表)
package com.bdh.mybatisplustest.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Users {
private Integer id;
private String username;
private Integer password;
}
4.创建Mapper接口
package com.bdh.mybatisplustest.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bdh.mybatispulstest.entity.Users;
//注入到mybatis-puls
public interface UserMapper extends BaseMapper<Users> {
}
5.在启动类上加上MyatispulstestApplication上添加上注解*@MapperScan(“com.xxx.xxx.mapper”)*,否则无法加载Mapper bean。
package com.bdh.mybatisplustest;
import org.mybatis.spring.annotation.MapperScan;
import