关于Mybatis+Eclipse快速映射成代码如下:
1.附件为mybaits自动生成工具,在mybatis文件夹下的eclipse目录下的features和plugins拷贝
到eclipse个相应目录覆盖即可完成安装,重启Eclipse。
2.将 mybatorConfig.xml文件放到项目任何目录下(如何生成如末尾演示图)。
文件中5点注意:
1
其中放的是数据库连接驱动包的路径。
2.connectionURL="jdbc:mysql://localhost:3306/mysql" userId="root" password="123456">
填写与数据库中的url。
3.mapper" targetProject="
PRO">
targetPackage: 生成实体文件存放位置
targetProject
放的是我们项目的名称
4.mapper" targetProject="
PRO">
同上(生成映射文件)
5.
enableInsert="true" enableSelectByPrimaryKey
="true"
enableUpdateByPrimaryKey
="true" enableDeleteByPrimaryKey
="true"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
相当于Hibernate作为全自动的生成映射文件的话,mybitis就是半自动,
原因:一次只能操作一个映射文件!
tableName对应数据库表名,domainObjectName为对象名。
3. 生成的时候右键点击 mybatorConfig.xml,单击 Generater Mybatis/iBatis...
注:其他地方勿改。
转载请注明原文地址: https://ju.6miu.com/read-664144.html