IDEA中SpringBoot+MyBatis工程的代码复用过程
2019-07-18 16:03
381 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_42437577/article/details/96433239
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>
总结:
写好一个模块的功能,其他模块可以套用该模块,以实现代码的复用,减轻了工作量,在实际工作中具有非常重要的现实意义。
相关文章推荐
- idea实现spring boot Mybatis框架的逆向工程
- 使用IDEA springboot 如何通过mybatis-generator自动生成代码
- springboot项目中使用mybatis逆向工程生成代码实例
- spring-boot集成mybatis问题1:IntellijIdea中j解决自动生成代码xml配置文件中出现“uri is not registered”问题
- Intellij IDEA springboot maven 配置mybatis-generator,自动从数据库中生成代码
- IDEA创建springboot + mybatis项目全过程
- IDEA搭建SpringBoot+Maven+Mybatis+MySQL-Web项目流程
- springboot+mybatis逆向工程
- IDEA搭建最简单的springboot小工程
- idea: springboot+mybatis+layui(一)
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- SpringBoot系列: 使用MyBatis maven插件自动生成java代码
- IDEA上搭建maven项目整合springboot+mybatis+shiro
- IDEA启动多个Spring Boot工程实例
- SpringBoot整合MyBatis逆向工程及 MyBatis通用Mapper实例详解
- idea+maven+springboot+mybatis
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- IDEA 集成的 Spring Boot 框架: thymeleaf + mysql + MyBatis +Druid +Redis + Maven + PageHelper (二)
- [SpringBoot]IDEA快速构建SpringBoot应用项目(二)整合Mybatis + Druid