Code provided
MyMapper class is provided by the author
to use the configuration file.
Set the package name plus the class name of
the data source
pojo the package name and our actual project is the corresponding
open our project foodie-dev project.
There are com.imooc.pojo packet
mapper generated xml path of
our projects in this folder correspond
in reverse engineering file folder is also the path
mapper package names
generated need to set the table in the database
table corresponding to the database .
You can put all the tables in the database are pasted here
GeneratorDisplay. This class is used to run our xml
parsing, and then carry out mutual step by step operation. Reverse generated.
We just need the right to run this
warning can not control.
File generation
mapper swells into a lot mapper file suffix.
General Mapper inherited the
entity classes generated under pojo package
if the field is exactly the same, it is not in front of this @Column annotation. If the field is underlined in the database, the generated entity class will be changed to the camel, which is inside the java development specification.
Notes also will be displayed.
mapper corresponding xml
as we generated ResultMapper
Copy the generated files to the project in real
例如先拷贝mapper下的mapper类文件。
Ctrl+C在生成的项目里面复制,
实体类的复制
添加引用pom.xml内
api项目的application.yml
在逆向工程里面 复制这个类 过来
foodie-dev-mapper工程内。先创建一个包
然后再复制过来
这样这里的错误提示就没了。
not-empty在做更新操作或者插入的操作会有一些判断,这些判断的时候,会判断某一个属性是否为null,是否为空,
推荐不依赖框架给你追加 不为空,推荐用手写的方式去判断。
identity设置为MySql。数据方言。
4
安装编译,看看当前代码有没有问题。
运行api
以上逆向工具使用完成。
结束