天天看點

myEclipse2014內建MyBatis插件自動生成代碼

內建過程:

1。選擇 Help->Install from site...

2。在彈出的對話框中點選右上角的Add按鈕。

3。在彈出的對話框中輸入

Name:mybatis

Location:https://dl.bintray.com/mybatis/mybatis-generator

(location中可以輸入以上位址,也可以點選Archive,選擇本地已經下載下傳好的jar、zip壓縮檔案:org.mybatis.generator.eclipse.site-1.3.5.201609070108.zip)

點選OK

4。在Work with 選擇mybatis - https://dl.bintray.com/mybatis/mybatis-generator或者自己選擇的本地路徑

(個人建議先下載下傳好,選擇本地安裝,這樣速度快,線上安裝太慢)

5。鈎選MyBatis Generator點選next

6。之後安裝完成,重新開機myeclipse即可

過程轉自:http://www.cnblogs.com/lzxlfly/p/6146012.html

生成代碼的過程:

建立generatorConfig.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="E:\Myeclipse\aaaaaaa\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.26-bin.jar"/>  

    <context id="DB2Tables" targetRuntime="MyBatis3">

        <commentGenerator>

            <property name="suppressDate" value="true" />

            <!-- 是否去除自動生成的注釋 true:是 : false:否 -->

            <property name="suppressAllComments" value="true" />

        </commentGenerator>

        <!--資料庫連結URL,使用者名、密碼 -->

        <jdbcConnection driverClass="com.mysql.jdbc.Driver"

            connectionURL="jdbc:mysql://localhost/scm" userId="root"

            password="951207">

        </jdbcConnection>

        <javaTypeResolver>

            <property name="forceBigDecimals" value="false" />

        </javaTypeResolver>

        <!-- 生成模型的包名和位置 -->

        <javaModelGenerator targetPackage="com.bean"

            targetProject="aaaaaaa">

            <property name="enableSubPackages" value="true" />

            <property name="trimStrings" value="true" />

        </javaModelGenerator>

        <!-- 生成映射檔案的包名和位置 -->

        <sqlMapGenerator targetPackage="com.mapper"

            targetProject="aaaaaaa">

            <property name="enableSubPackages" value="true" />

        </sqlMapGenerator>

        <!-- 生成DAO的包名和位置 -->

        <javaClientGenerator type="XMLMAPPER"

            targetPackage="com.dao" targetProject="aaaaaaa">

            <property name="enableSubPackages" value="true" />

        </javaClientGenerator>

        <!-- 要生成哪些表 -->

        <table tableName="account" domainObjectName="AboutDto"

            enableCountByExample="false" enableUpdateByExample="false"

            enableDeleteByExample="false" enableSelectByExample="false"

            selectByExampleQueryId="false"></table>

    </context>

</generatorConfiguration>   

myEclipse2014內建MyBatis插件自動生成代碼

本文轉自:http://blog.csdn.net/u014481096/article/details/45025607

myeclipse版本為其他的時可如下操作:

下載下傳MyBatis_Generator_1.3.1.zip下載下傳位址http://download.csdn.net/detail/rosener/9758480

然後将該jar包解壓,将features檔案夾和plugins檔案夾直接copy到MyEclipse安裝的dropins的路徑下。重新開機Myeclipse則完成操作