zoukankan      html  css  js  c++  java
  • Ruoyi-Cloud-增加单元测试和Mybatis-plus

    Ruoyi-Cloud-增加单元测试和Mybatis-plus

    目的:

    在RuoYiSystem模块中增加Mybatis-Plus和单元测试

    Mybatis-Plus

    参考:http://doc.ruoyi.vip/ruoyi/document/cjjc.html#集成mybatis-plus实现mybatis增强

    重点是添加依赖后要在nacos中修改application.yml配置

    主要步骤:

    • 在ruoyi-system的pom.xml中增加依赖
    <!-- mybatis-plus -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
    </dependency>
    
    • 修改nacos中的application.yml

    • 增加mybatis-plus的configuration

      image-20210612165701435

    • 修改实体类的基类:

      由于原来的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>
    

  • 相关阅读:
    岛田庄司《占星术杀人魔法》读后感
    OutputCache祥解
    ZOJ Monthly, June 2014 月赛BCDEFGH题题解
    接口和抽象类有什么差别
    C语言指针的初始化和赋值
    深入探讨this指针
    郁 繁体为“鬰” 古同 “鬱”
    socketpair的使用
    Android的FrameLayout使用要注意的问题
    下确界和上确界
  • 原文地址:https://www.cnblogs.com/ShineTan/p/14878592.html
Copyright © 2011-2022 走看看