【Eclipse】使用Mybatis Generator提高你的效率

安装MyBatis Generator插件

两种安装方式

  1. 在Eclipse的插件市场,搜索MyBatis Generator,直接点击安装即可
打开Eclipse插件市场

搜索MyBatis Generator

2.手动配置更新网站到https://dl.bintray.com/mybatis/mybatis-generator,然后到下载插件压缩包https://github.com/mybatis/generator/releases,安装插件即可

2.1 Install New Software
2.2 点击Add
2.3 Add Repository
2.4 选择Mybatis Generator,下一步下一步安装即可

如何使用

  1. 创建配置文件
    1.1 File>New>Other...
    新建文件

    1.2 选择Mybatis Generator Configuration File
Mybatis Generator Configuration File
  1. 填写配置文件,以下几个为必填项。另外需要配置classPathEntrygeneratorConfiguration节点下。
    <pre>
    jdbcConnection 指定数据库连接信息
    javaModelGenerator 指定目标项目和包
    sqlMapGenerator 指定目标项目和包
    javaClientGenerator
    table 至少一个数据库表
    </pre>
    我的配置如下所示:
    <pre>
    <generatorConfiguration>
    <classPathEntry location="/Users/liyanan/Downloads/mysql-connector-java-6.0.6.jar" />
    <context id="context1">
    <jdbcConnection connectionURL="jdbc:mysql://192.168.1.1:3306/dbname" driverClass="com.mysql.jdbc.Driver" password="mengmidogwhere2020" userId="root" />
    <javaModelGenerator targetPackage="com.lyn.keepdata" targetProject="KeepData" />
    <sqlMapGenerator targetPackage="com.lyn.keepdata" targetProject="KeepData" />
    <javaClientGenerator targetPackage="com.lyn.keepdata" targetProject="KeepData" type="XMLMAPPER" />
    <table tableName="backend_menu">
    </table>
    </context>
    </generatorConfiguration>
    </pre>

-EOF-

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. 简介 1.1 什么是 MyBatis ? MyBatis 是支持定制化 SQL、存储过程以及高级映射的优秀的...
    笨鸟慢飞阅读 5,571评论 0 4
  • 本文章仅作为个人笔记 项目搭建参考于博客:http://blog.csdn.net/zhshulin/articl...
    草丛里的黄盖阅读 3,479评论 0 3
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,868评论 18 139
  • 那份情,那么深,那么疼 若,不曾遇见,我们就不会默默相依,寂静欢喜。若,不曾遇见,我们就不会有深深牵挂,相互依恋。...
    蕊茉尔阅读 311评论 1 5
  • 也许,你的外表并不是很漂亮很美丽,但你一定要收拾的干净利落;如果你没有智慧聪明的头脑,至少你要让自己可爱懂事。 一...
    逗比小女仆阅读 305评论 1 6