myeclipse10安装mybatis自动生成bean文件插件

1. 从github下载压缩包https://github.com/mybatis/generator

2. 在MyEclipse安装目录下新建myPlugin目录,再在myPlugin下新建mybatis文件夹

3. 将 下载的压缩包generator-master\eclipse\UpdateSite 里面的文件放在新建的myPlugin目录下

4.  在Myeclipse安装目录dropins下,新建mybatis.link文件,并在文件中写入刚才放置文件的路径:

        path=C:\\Users\\Administrator\\AppData\\Local\\MyEclipse\\MyEclipse 10\\myPlugin\\mybatis

5. 下载jdbc的jar包,此处使用mysql-connector-java-5.1.6-bin.jar

6. 在项目中放入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" >  
  
<!-- 此文件只是mybatis 的数据库自动生成映射文件,实体类,接口等方法的,发布时,不用提交此文件,也可删除 -->  
  
<generatorConfiguration>  
    <!-- 引用的jdbc的类路径,这里将jdbc jar和generator的jar包放在一起了 -->  
    <classPathEntry location="D:\mylib\mysql-connector-java-5.1.6-bin.jar"/>  
    <context id="context1" targetRuntime="MyBatis3Simple">  
          
        <commentGenerator>  
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->  
            <property name="suppressAllComments" value="false"/>  
            <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->    
          </commentGenerator>  
          
        <!-- 指定的jdbc的连接信息 -->  
        <jdbcConnection   
            driverClass="com.mysql.jdbc.Driver"   
            connectionURL="jdbc:mysql://192.168.1.100:3306/demo4"   
            userId="root"   
            password="xxx" />  
          
        <!-- 类型转换 -->    
        <javaTypeResolver>    
            <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->    
            <property name="forceBigDecimals" value="false"/>    
        </javaTypeResolver>    
          
        <!-- 生成实体类地址 Model -->         
        <javaModelGenerator targetPackage="com.system.pojo" targetProject="ssmDemo\src" >  
            <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->    
            <property name="enableSubPackages" value="false"/>    
            <!-- 是否针对string类型的字段在set的时候进行trim调用 -->    
            <property name="trimStrings" value="true"/>    
        </javaModelGenerator>  
          
        <!-- 生成map.xml文件 XML -->       
       <!--  <sqlMapGenerator targetPackage="com.system.pojo" targetProject="ssmDemo\src" >  
            是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName]    
            <property name="enableSubPackages" value="false" />   
        </sqlMapGenerator>  --> 
          
        <!-- 生成map.xml对应client,也就是接口DAO -->    
       <!--  <javaClientGenerator targetPackage="com.system.pojo" targetProject="ssmDemo\src" type="XMLMAPPER" >  
            是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName]    
            <property name="enableSubPackages" value="false" />   
        </javaClientGenerator>   -->
          
        <!--   
            schema:数据库名   
            tableName:对应的数据库表   
            domainObjectName:要生成的实体类   
            enable*ByExample: 是否生成 example类     
        -->   
        <table schema="olastic4" tableName="member" domainObjectName="member"   
            enableCountByExample="false"  enableDeleteByExample="false"   
            enableSelectByExample="false"  enableUpdateByExample="false">  
              
         <!-- 忽略列,不生成bean 字段 -->
            <!-- <ignoreColumn column="FRED" />    
         		   指定列的java数据类型    
            <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />    --> 
        </table>  
          
    </context>  
</generatorConfiguration>  
7. 重启Myeclipse,鼠标右击generatorConfig.xml 文件,在弹出的菜单中选择Generate MyBatis/iBATIS Artifacts 即可生成所需文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值