惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 一 缕 阳 光

macOS 安装cocoapods记录 Flowable笔记 VUE项目中同时使用API代理与MockJs Ruoyi-Cloud-服务间的调用 使用Typro+dotnet-cnblog在博客园写博客 T4模板插件 使用Open Live Writer在博客园中写博文 Windows与CentOS8虚拟机网络共享与互通 因数据库连接串导致的netcore发布到IIS后报500错误 【转】使用ASP.NET Web API构建Restful API 表单设计器的探索 解决C#中dynamic类型作为泛型参数的反射问题 【原创】AltiumDesigner 6 的自定义菜单 估计项目的重要几点 从Project 2007导出WBS图表到Visio 2007 CMS: DNN And Umbraco ORA-01489: result of string concatenation is too long 【原创】长尾关键词的挖掘与使用方法 【原创】Tesseract-OCR 3.02 训练笔记
Ruoyi-Cloud-增加单元测试和Mybatis-plus
一 缕 阳 光 · 2021-06-12 · via 博客园 - 一 缕 阳 光

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>