我是靠谱客的博主 健康饼干,这篇文章主要介绍Mybatis Generator eclipse配置详解,现在分享给大家,希望可以做个参考。

1.下载插件 https://pan.baidu.com/s/1pLTeAgV
2.把里面的features、plugins拷贝到eclipse安装目录的相应目录中
3.​重启eclipse,New->Other->MyBatis->MyBtis Generator Configuration File,选择generatorConfig.xml文件的放置位置
4.generatorConfig.xml文件​的具体配置如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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="D:maven-repositorymysqlmysql-connector-java5.1.30mysql-connector-java-5.1.30.jar" /> <context id="context1" > <commentGenerator> <property name="javaFileEncoding" value="UTF-8" /><!-- 是否去除自动生成的注释 true:是 , false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- true代表取消时间戳,避免重复提交SVN --> <property name="suppressDate" value="true"/> <!-- 数据库链接URL、用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.10.68:3306/housecall" userId="dev" password="123456" /> <!-- 生成模型的包名和位置 --> <javaModelGenerator targetPackage="com.siping.web.bean" targetProject="postpartum_housecall/src/main/java" /> <!-- 生成映射文件的包名和位置 --> <sqlMapGenerator targetPackage="com.siping.userPage.mapper.sql" targetProject="postpartum_housecall/src/main/java" /> <!-- 生成DAO的包名和位置 --> <javaClientGenerator targetPackage="com.siping.userPage.mapper" targetProject="postpartum_housecall/src/main/java" type="XMLMAPPER" /> <!-- 要生成的表(tableName:表名 ,domainObjectName:生成的文件主名。 如下,会生成BabyVisitRecord. --> <!-- 5个false是为了去掉ByExample后缀的方法 --> <table schema="ssm1" tableName="baby_visit_record" domainObjectName="babyVisitRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> </context> </generatorConfiguration>

5.右键generatorConfig.xml选择generator MyBatis/iBATIS Artifacts文件就会生成
6.​按需修改插件(xml空格、bean换行、从数据库取注释等),进入Window->Show View->Plug-in Development->plug-ins,找到org.mybatis.generator.core,右键Import As->Source Project,此时左侧会生成项目可以对java文件进行修改了 (参考:http://www.blogjava.net/bolo/archive/2016/08/17/423683.html#431607),修改完成后右键项目Export->Plug-in Development->Deployable plug-ins and fragments->next,填写输出位置,options要改成勾选第一项和最后一项否则会出现乱码,finish完成
7.解决中文注释乱码,找到eclipse安装目录​下的eclipse.ini文件,在最后加上:-Dfile.encoding=UTF-8即可

最后

以上就是健康饼干最近收集整理的关于Mybatis Generator eclipse配置详解的全部内容,更多相关Mybatis内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(83)

评论列表共有 0 条评论

立即
投稿
返回
顶部