一秒生成JAVA后端CRUD代码(作者:万润)
1. 生成工具插件-安装
IDEA工具
1.点击File—》settings—》Plugins
2. 插件使用
2.1新建GroupName : 这里用唯一名称即可
2.2 点击加号,新增”controller.java.vn、entity.java.vm、mapper.java.vm、mapper.xml.vm、service.java.vm、serviceImpl.java.vm“
3. 修改模版
默认的分页有点问题,转成mybatis-plus的版本即可
1.controller.java.vm
1 | ##定义初始变量 |
2.entity.java.vm
1 | ##导入宏定义 |
3.mapper.java.vm
1 | ##定义初始变量 |
4.mapper.xml.vm
1 | ##引入mybatis支持 |
5.service.java.vm
1 | ##定义初始变量 |
6.serviceImpl.java.vm
1 | ##定义初始变量 |
4. 开始一秒生成
右键IDEA的Database的某一张表,如下图显示:
4.1 点击Generate Code(old)即可,新的不怎么好用。
4.2 选择参数如下图:
4.3 点击OK,大功造成
5. 前端测试(分页)
浏览器地址:http://localhost:8080/student/page?current=1&size=100
返回结果:
1 {"success":true,"code":"200","message":"成功","data":{"body":{"records":[{"id":"2","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"222","age":222},{"id":"3","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"333","age":333},{"id":"4","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"444","age":1},{"id":"5","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"555","age":1},{"id":"6","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"666","age":6},{"id":"7","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"777","age":7},{"id":"8","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"888","age":8},{"id":"9","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"999","age":9},{"id":"10","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"1212","age":12},{"id":"11","createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateDept":null,"updateTime":null,"name":"wwww","age":100},{"id":"1677203967213711362","createUser":null,"createDept":null,"createTime":"2023-07-07 14:30:01","updateUser":null,"updateDept":null,"updateTime":null,"name":"k3","age":19}],"total":11,"size":100,"current":1,"orders":[],"optimizeCountSql":true,"searchCount":true,"maxLimit":null,"countId":null,"pages":1}}}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 万润の博客!
评论