mybatis generator一款mybatis反向生成工具

本文详细介绍了如何将MyBatis Generator作为Eclipse插件进行安装和使用,包括下载、安装步骤以及配置文件的设置,帮助开发者更便捷地生成MyBatis的持久层代码。

本文主要介绍mybatis generator作为插件在eclipse中使用

有mybatis generator windows直接使用的版本,其和这配置文件类似,个人觉得当做插件来用更顺手

百度MyBatis_Generator_1.3.1,下载,减压,并复制

并复制这两个文件到自己的eclipse安装目录中,不会eclipse插件安装的请baidu。

重启后new---other就有了安装好的插件,新建出来是generator的xml配置文件



generator的xml配置文件介绍,直接贴我的配置文件源文件有注释

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration >
	<classPathEntry location="C:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar"/>
  <context id="context1" >
  	<commentGenerator>
  		 <!-- 是否去除自动生成的注释 true:是 : false:否 --> 
    	<property name="suppressAllComments" value="true" />  
  	</commentGenerator>
    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/spring" userId="root" password="" />
    <javaModelGenerator targetPackage="com.baobaotao.domain" targetProject="spring/src/main/java" />
    <sqlMapGenerator targetPackage="com.baobaotao.dao.mapper.xml" targetProject="spring/src/main/java" />
    <javaClientGenerator targetPackage="com.baobaotao.dao.mapper" targetProject="spring/src/main/java" type="XMLMAPPER" />
    <!-- domainObjectName对应的POJO的类名,其它true,false去掉一些生成example无用的代码 -->
    <table tableName="t_user" domainObjectName="User"  enableInsert="true"  
            enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"  
            enableDeleteByPrimaryKey="true" enableSelectByExample="false"  
            enableDeleteByExample="false" enableCountByExample="false"  
            enableUpdateByExample="false">
      <columnOverride column="user_id" property="userId" />
      <columnOverride column="user_name" property="userName" />
      <columnOverride column="credits" property="credits" />
      <columnOverride column="password" property="password" />
      <columnOverride column="last_visit" property="lastVisit" />
      <columnOverride column="last_ip" property="lastIp" />
    </table>
   <table tableName="t_login_log" domainObjectName="LoginLog"  enableInsert="true"  
            enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"  
            enableDeleteByPrimaryKey="true" enableSelectByExample="false"  
            enableDeleteByExample="false" enableCountByExample="false"  
            enableUpdateByExample="false">
      <columnOverride column="login_log_id" property="loginLogId" />
      <columnOverride column="user_id" property="userId" />
      <columnOverride column="ip" property="ip" />
      <columnOverride column="login_datetime" property="loginDate" />
    </table>
  </context>
</generatorConfiguration>

编辑好之后,选中文件右键直接选择Generate Mybatis/iBatis Artifacts,就可以直接生成


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值