前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IDEA 自动生成mapper

IDEA 自动生成mapper

作者头像
六个周
发布2022-10-28 11:50:41
1.4K0
发布2022-10-28 11:50:41
举报
文章被收录于专栏:六个周

第一步:

需要两个jar包(aymsp-alipay下备份):

  • mybatis-generator-core-1.4.0.jar
  • mysql-connector-java-5.1.31.jar (数据库驱动)

第二步:

配置 generatorConfig.xml文件

代码语言:javascript
复制
<?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>
 
  <!--MySQL连接驱动-->
  <classPathEntry location="mysql-connector-java-5.1.31.jar" />
  
  <!--数据库链接URL,用户名、密码 -->
  <context id="MySQL" targetRuntime="MyBatis3">

    <commentGenerator>  
            <property name="suppressDate" value="true"/>  
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->  
            <property name="suppressAllComments" value="true"/>  
    </commentGenerator> 
    
    
    <!----------------- 第一个需要修改的地方 ----------------->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
        connectionURL="jdbc:mysql://localhost:3306/aymspdb"
        userId="root"
        password="pass">
    </jdbcConnection>
 
    
    
    
    <!--是否启用java.math.BigDecimal-->
    <javaTypeResolver >
      <property name="forceBigDecimals" value="false" />
    </javaTypeResolver>
    
    <!----------------- 第二个需要修改的地方 ----------------->
    <!-- 生成模型的包名和位置--> 
    <javaModelGenerator targetPackage="org.ayfoundation.api.impl.app.alipay.entity.model" targetProject="output">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>
    
    
     <!----------------- 第三个需要修改的地方 ----------------->
    <!-- 生成映射文件的包名和位置-->
    <sqlMapGenerator targetPackage="test.xml"  targetProject="output">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>
    
    
     <!----------------- 第四个需要修改的地方 ----------------->
    <!-- 生成DAO的包名和位置--> 
    <javaClientGenerator type="XMLMAPPER" targetPackage="org.ayfoundation.api.impl.app.alipay.entity.dao"  targetProject="output">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>
    
    
     <!----------------- 第五个需要修改的地方 ----------------->
    <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
    <table tableName="app_alipay_downloadbill" domainObjectName="AlipayBillInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="true">
    </table>
    
  </context>
</generatorConfiguration>

第三步:

java -jar mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-05-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第一步:
  • 第二步:
  • 第三步:
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档