




























目的:
在RuoYiSystem模块中增加Mybatis-Plus和单元测试
参考:http://doc.ruoyi.vip/ruoyi/document/cjjc.html#集成mybatis-plus实现mybatis增强
重点是添加依赖后要在nacos中修改application.yml配置
主要步骤:
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
修改nacos中的application.yml
增加mybatis-plus的configuration

修改实体类的基类:
由于原来的BaseEntity中有一些与数据库无关的属性,需要使用注解将其标识为@TableField(exist = false),而此类在的公共模块中并不依赖Mybatis-Plus,所以,可以复制一个基类名为MbpBaseEntity,放在ruoyi-system中,再将需要使用Mybatis-plus的实体类继承此类。
/**
* 菜单权限表 sys_menu
*
* @author ruoyi
*/
public class SysMenu extends MbpBaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
private Long menuId;
/** 菜单名称 */
private String menuName;
@TableField(exist = false)
/** 父菜单名称 */
private String parentName;
@TableField(exist = false)
/** 父菜单ID */
private Long parentId;
……
}
在ruoyi-modules-system模块的pom.xml中增加以下依赖即可:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。