zoukankan      html  css  js  c++  java
  • eclipse中mybatis自动生成插件使用

      

    对于使用Mybatis的开发者来说, 使用mybatis generator来生成mapper 以及配置文件, 可以大大简化工作, mybatis generator有多种工作方式, eclipse插件是一种比较友好的方式.

    第一, 首先,到http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=2947754, 拖到eclipse工作区,进行插件安装:

    或者使用在线安装,地址为 http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/

    安装完毕之后,新建generatorConfig.xml, 用来控制文件生成

    第二,对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="C:Usersviruser.v-desktop.m2
    epositorymysqlmysql-connector-java5.1.30mysql-connector-java-5.1.30.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://171.21.202.49:5432/db_lzt" userId="root" password="123456">    
            </jdbcConnection>    
            <javaTypeResolver>    
                <property name="forceBigDecimals" value="false"/>    
            </javaTypeResolver>    
            <!-- 生成模型的包名和位置-->    
            <javaModelGenerator targetPackage="com.lzt.model" targetProject="mvntestsrcmainjava">    
                <property name="enableSubPackages" value="true"/>    
                <property name="trimStrings" value="true"/>    
            </javaModelGenerator>    
            <!-- 生成映射文件的包名和位置-->    
            <sqlMapGenerator targetPackage="com.lzt.mapping" targetProject="mvntestsrcmainjava">    
                <property name="enableSubPackages" value="true"/>    
            </sqlMapGenerator>    
            <!-- 生成DAO的包名和位置-->    
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.lzt.mapper" targetProject="mvntestsrcmainjava">    
                <property name="enableSubPackages" value="true"/>    
            </javaClientGenerator>    
            <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->    
            <table tableName="user_t" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
        </context>    
    </generatorConfiguration>    

    第三,然后右击配置文件, 选择Generate Mybatis Artifacts 即可

  • 相关阅读:
    字符串转list
    vant下拉单选
    断点续传(上传)C#版
    7z压缩测试
    SQL SERVER查看表字段信息
    FTP安全组设置
    Unable to find @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest
    Charles 抓包使用教程
    董明珠语录
    京东 Vue3 组件库 nutui 3.0 发布,支持小程序开发
  • 原文地址:https://www.cnblogs.com/hdulzt/p/6475929.html
Copyright © 2011-2022 走看看