发布时间:2020-12-05 21:21:55来源:Android编程精选
Python实战社群
Java实战社群
长按识别下方二维码,按需求添加
扫码关注添加客服
进Python社群▲
扫码关注添加客服
进Java社群▲
来源丨blog.csdn.net/m0_37922192/
article/details/109248865
1.拷贝Mybatis反向工程配置文件到项目的根目录下2.根据项目及表的情况,修改GeneratorMapper.xml配置如果使用高版本,驱动类变为:com.mysql.cj.jdbc.Driver
url后面应该加属性nullCatalogMeansCurrent=true,否则生成有问题
当前版本MySQL数据库为5.7
主要根据注释来修改自己的内容
这个时候可以不用理会,项目也是会正常运行的,当然也可以这样
添加之后就不会报红了
5.生成的文件自动生成model/Student、实体类
以及StudentMapper,接口
StudentMapper.xml具体对数据库的操作
这样方便我们使用,具体的下面详细介绍,注意看注释
Student
packagecom.md.springboot.model;publicclassStudent{privateIntegerid;privateStringname;privateIntegerage;publicIntegergetId(){returnid;}publicvoidsetId(Integerid){this.id=id;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicIntegergetAge(){returnage;}publicvoidsetAge(Integerage){this.age=age;}}123456789101112131415161718192021222324252627282930313233StudentMapper
packagecom.md.springboot.mapper;importcom.md.springboot.model.Student;publicinterfaceStudentMapper{intdeleteByPrimaryKey(Integerid);intinsert(Studentrecord);intinsertSelective(Studentrecord);StudentselectByPrimaryKey(Integerid);intupdateByPrimaryKeySelective(Studentrecord);intupdateByPrimaryKey(Studentrecord);}1234567891011121314151617StudentMapper.xml
程序员专栏
扫码关注填加客服
长按识别下方二维码进群
近期精彩内容推荐:
在看点这里好文分享给更多人↓↓