亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Mybatis Generator 逆向工程

標簽:
Java MySQL

之前为了锻炼自己的SQL语句的能力在使用Mybatis时都是自己书写Mapper.xml等相关文件,现在开发工作越来越多,必须使用自动化生成工具来生成一部分代码,从而加快开发的效率。
使用Mybatis generator有几种方法。这次使用的是java代码加XML配置的方式。
1、从github中下载Mybatis generator需要的jar包。mybatis-generator-core-1.3.2-bundle
我是在使用代理的情况下打开的github,如何打不开去我群里问吧【软件开发技术交流】:
下载的压缩包中有你需要的jar包,里面还有相关的文档。不过是英文的,知道英文的重要性了吧。
2、按照文档中给的例子操作。下面给出关于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="mysql-connector-java-5.0.6-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/test" userId="test" password="test">  
            </jdbcConnection>  
            <javaTypeResolver>  
                <property name="forceBigDecimals" value="false"/>  
            </javaTypeResolver>  
            <!-- 生成模型的包名和位置-->  
            <javaModelGenerator targetPackage="test.model" targetProject="src">  
                <property name="enableSubPackages" value="true"/>  
                <property name="trimStrings" value="true"/>  
            </javaModelGenerator>  
            <!-- 生成映射文件的包名和位置-->  
            <sqlMapGenerator targetPackage="test.mapping" targetProject="src">  
                <property name="enableSubPackages" value="true"/>  
            </sqlMapGenerator>  
            <!-- 生成DAO的包名和位置-->  
            <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao" targetProject="src">  
                <property name="enableSubPackages" value="true"/>  
            </javaClientGenerator>  
            <!-- 要生成哪些表-->  
            <table tableName="about" domainObjectName="AboutDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
            <table tableName="user" domainObjectName="UserDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
            <table tableName="syslogs" domainObjectName="SyslogsDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
        </context>  
    </generatorConfiguration>  
點擊查看更多內容
19人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
JAVA開發工程師
手記
粉絲
5
獲贊與收藏
187

關注作者,訂閱最新文章

閱讀免費教程

感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消