eclipse中mybatis generator插件的安装与使用,实现自动生成代码

摘要:
xmlversion=“1.0”encoding=“UTF-8”?˃˃˂proertyname=“enable SubPackage”value=!

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

下载后解压:

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第1张

选择任意一个版本的jar放到eclipse的features目录下即可

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第2张

选择任意一个版本的jar放到eclipse的plugins目录下即可

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第3张

重启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:ackup
epositorymysqlmysql-connector-java5.1.40mysql-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.codesrcmainjava">
            <property name="enableSubPackages"value="true" />
            <property name="trimStrings"value="true" />
        </javaModelGenerator>
        <!--mapping package and location -->
        <sqlMapGenerator targetPackage="cn.zsmy.mapper"targetProject="palmdoctor.codesrcmainjava">
            <property name="enableSubPackages"value="true" />
        </sqlMapGenerator>
        <!--dao package and location -->
        <javaClientGenerator type="XMLMAPPER"targetPackage="cn.zsmy.mapper"targetProject="palmdoctor.codesrcmainjava">
            <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的。

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第4张

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第5张

eclipse中mybatis generator插件的安装与使用,实现自动生成代码第6张

没报错就是成功了

去掉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>
我的修改:
eclipse中mybatis generator插件的安装与使用,实现自动生成代码第7张
运行之后,确实没有了。

免责声明:文章转载自《eclipse中mybatis generator插件的安装与使用,实现自动生成代码》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇五大主流浏览器及内核第三方库-时间函数dateutil下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

[Spring] 学习Spring Boot之二:整合MyBatis并使用@Trasactional管理事务

一、配置及准备工作 1、在 Maven 的 pom 文件中新增以下依赖: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>r...

Mybatis多表查询(一对一、一对多、多对多)(转)

Mybatis的多表级联查询 。 一对一可以通过实现,一对多和多对多通过实现。 元素,可以灵活选择属性column使用哪个字段进行鉴别。 一. 一对一的级联查询 对user_t表和book_t表进行连接查询。sql语句类似如下: select b.book_id,b.name,b.publishers,a.id,a.user_name from user...

MyBatis Plus 批量数据插入功能,yyds!

最近 Review 小伙伴代码的时候,发现了一个小小的问题,小伙伴竟然在 for 循环中进行了 insert (插入)数据库的操作,这就会导致每次循环时都会进行连接、插入、断开连接的操作,从而导致一定的性能问题,简化后代码如下: /** * 插入操作 */ @RequestMapping("/save") public Object save() {...

MyBatis映射文件(编写SQL语句;可有可无(无的时候,使用注解编程))

 一、映射文件  1.简单的增删改(需要commit)---查 MyBatis允许增删改直接定义以下类型返回值   Integer、Long、Boolean、void 我们需要手动提交数据。   sqlSessionFactory.openSession();===>需要手动提交   sqlSessionFactory.openSession(tr...

使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件

出处:http://www.cnblogs.com/lichenwei/p/4145696.html Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件。 1、相关文件 关于Mybatis-Generator的下载可以到这...

[MyBatis]五分钟向MySql数据库插入一千万条数据 批量插入 用时5分左右

本例代码下载:https://files.cnblogs.com/files/xiandedanteng/InsertMillionComparison20191012.rar 我的数据库环境是mysql Ver 14.14 Distrib 5.6.45, for Linux (x86_64) using EditLine wrapper 这个数据库是安装...