git地址:https://github.com/mybatis/generator
下载后解压:
选择任意一个版本的jar放到eclipse的features目录下即可
选择任意一个版本的jar放到eclipse的plugins目录下即可
重启eclispe
需要mybatis-generator-core.jar
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
右键-new,会有MyBatis,在指定项目目录下生成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>
<!-- 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的。
没报错就是成功了
去掉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>
我的修改:
运行之后,确实没有了。