IDEA中SpringBoot+MyBatis工程的代码复用过程

1.修改配置文件generatorConfig.xml,逆向工程生成dao

<table tableName="student" domainObjectName="Student"></table>

2.maven compile
3.注释掉generatorConfig.xml中如下标签

<!-- <table tableName="student" domainObjectName="Student"></table> -->
<table tableName="aaa" domainObjectName="aaa"></table>

4.修改model 的Example,继承BaseModelExample,实现分页

public class StudentExample extends BaseModelExample

5.修改mapper.xml文件,增加limit

 <select id="selectByExample" parameterType="wang.doug.frame.model.StudentExample" resultMap="BaseResultMap">
  select
  <if test="distinct">
    distinct
  </if>
  <include refid="Base_Column_List" />
  from student
  <if test="_parameter != null">
    <include refid="Example_Where_Clause" />
  </if>
  <if test="orderByClause != null">
    order by ${orderByClause}
  </if>
  <if test="rowIndex != null and pageSize != null and pageSize > 0">
    limit #{rowIndex},#{pageSize}
  </if>
</select>

6.写service
CTRL+R
在这里插入图片描述

使用模板复制一份,查找替换。将School替换为Student,school替换为student

数据库中tinyint改int再重新启用逆向工程,name改RealName,int改String,删WithBLOBs,把错误的地方
注释。。。等等,注意实现类的错误改了,相对应的,接口的错误也要改了。

7.写Controller

使用模板复制一份,查找替换。将School替换为Student,school替换为student

8.resources/templates 页面需要修改四个文件

修改js/index_js.html中的bootstrapTable的列
修改new.html中表单项,页面中表单元素可以到angle等bootstrap模版中查找
注意:表单元素必须要有结束标签,否则会报错!

9.resources/common/left.html 增加菜单链接

<li>
    <a href="/student/index.html">   
       <span>学生</span>
    </a>
</li>
总结:

写好一个模块的功能,其他模块可以套用该模块,以实现代码的复用,减轻了工作量,在实际工作中具有非常重要的现实意义。

  • 22
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值