eclipse中mybatis generator插件的安裝與使用,實現自動生成代碼

 

git地址:https://github.com/mybatis/generatorhtml

下載後解壓:java

 

選擇任意一個版本的jar放到eclipse的features目錄下便可mysql

 

 選擇任意一個版本的jar放到eclipse的plugins目錄下便可git

 

重啓eclispegithub

 

須要mybatis-generator-core.jarsql

<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>mybatis

 

右鍵-new,會有MyBatis,在指定項目目錄下生成generatorConfig.xmloracle

如下是我配置的app

<?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>
    <!-- oracle lib location -->
    <classPathEntry location="E:\backup\repository\mysql\mysql-connector-java\5.1.40\mysql-connector-java-5.1.40.jar" />
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressAllComments" value="true" />
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://192.168.1.2:3306/palm_2_0_16" userId="root"
            password="sqj888">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
        
        
        <!-- model package and location -->
        <javaModelGenerator targetPackage="cn.zsmy.entity" targetProject="palmdoctor.code\src\main\java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
        <!-- mapping package and location -->
        <sqlMapGenerator targetPackage="cn.zsmy.mapper" targetProject="palmdoctor.code\src\main\java">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
        <!-- dao package and location -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="cn.zsmy.mapper" targetProject="palmdoctor.code\src\main\java">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>
        
        
        
        <table tableName="tb_hello" domainObjectName="Hello"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
        
            
    </context>
</generatorConfiguration>

 

已存在generatorConfig.xml就不須要新建了,也能夠直接copy的。dom

 

 

 

 

 

 

 

沒報錯就是成功了 

 

 

 

 

去掉Mybatis Generator生成的一堆 example

原文:http://www.cnblogs.com/lyh421/p/5672569.html

mybatis generator自動生成的代碼裏總是有一堆example,須要改的時候,generatorConfig.xml文件的配置的方法以下:
 
<table schema="general" tableName="tb_table_name" domainObjectName="EntityName"
    enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false" >
    <property name="useActualColumnNames" value="true"/>
</table>
 
個人修改:
 
 
運行以後,確實沒有了。
相關文章
相關標籤/搜索