博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Mybatis-Plus快速进行增删改查
阅读量:3960 次
发布时间:2019-05-24

本文共 1370 字,大约阅读时间需要 4 分钟。

pom.xml引入jar

org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.0
com.baomidou
mybatis-plus-boot-starter
3.0.6

#application.properties配置文件中设置MybatisPlus的mapper文件扫描

mybatis-plus.mapper-locations=classpath*:扫描包下的路径/*Mapper.xml//我的路径是mybatis-plus.mapper-locations=classpath*:com/zgf/springboot03loggin/mapper/xml/*Mapper.xml

mapper层的接口继承BaseMapper泛型类传递一个需要执行增删改查的实体类,

@Mapperpublic interface IPhoneMapper extends BaseMapper
<实体类>
{
}

entity类代码

//自动封装实体类数据@Data//标识使用的数据库表@TableName("book")public class BookEntity {
//自动映射数据库主键 @TableId(type = IdType.AUTO) private int id; //@TableField("数据库列名") private String name; private String author; private int tid; private double Bmoney;}

Service层

public interface IBookService extends IService
{
}

service的实现层

public class IBookServiceImpl extends ServiceImpl
implements IBookService {
}Controller层```java@Controllerpublic class BookController {
@Resource(name = "iBookServiceImpl") IBookService iBookService; @RequestMapping("/select") @ResponseBody public String select(){
return JSON.toJSONString(iBookService.list()); }}

转载地址:http://smqzi.baihongyu.com/

你可能感兴趣的文章
Hibernate中Criteria的完整用法
查看>>
sql jsp
查看>>
spring beans beanfactory applicationcontext
查看>>
使用ORM工具进行数据访问
查看>>
使用ORM工具进行数据访问
查看>>
编译与部署Eclipse+Tomcat+MySQL+Liferay4.1.2
查看>>
POJ3728,The merchant(倍增LCA+分治)
查看>>
2019 ICPC Malaysia National,E. Optimal Slots(01背包变形)
查看>>
洛谷P1638 逛画展(双向队列)
查看>>
POJ2892,Tunnel Warfare(线段树维护连续区间)
查看>>
POJ3468,A Simple Problem with Integers(线段树-区间查询-区间更新)
查看>>
杭电ACM——6463(思维)
查看>>
杭电ACM——1061,Rightmost Digit(思维)
查看>>
杭电ACM——1087,Super Jumping! Jumping! Jumping!(DP)
查看>>
杭电ACM——fatmouse's speed(DP)
查看>>
杭电ACM——毛毛虫(DP)
查看>>
杭电ACM——humble numbers(DP)
查看>>
杭电ACM——6467,简单数学题(思维)
查看>>
杭电ACM——天上掉馅饼(DP)
查看>>
杭电ACM——1086,You can Solve a Geometry Problem too(思维)
查看>>