代码下载地址:https://download.csdn.net/download/hua_faded/10671547

一、配置Maven pom.xml 文件

在pom.xml增加以下插件:

<build><finalName>zsxt</finalName> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin> </plugins> </build>

配置好Maven插件,下面需要配置插件需要配置文件

二、在maven项目下的src/main/resources 目录下建立名为 Maven的项目配置文件存放路径如下图:generatorConfig.xml和generator.properties配置文件,

Maven的项目配置文件存放路径如下图:

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> <!--导入属性配置--> <properties resource="generator.properties"></properties> <!--指定特定数据库的jdbc驱动jar包的位置--> <classPathEntry location="${jdbc.driverLocation}"/> <context id="default" targetRuntime="MyBatis3"> <!-- optional,旨在创建class时,对注释进行控制 --> <commentGenerator> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--jdbc的数据库连接 --> <jdbcConnection driverClass="${jdbc.driverClass}" connectionURL="${jdbc.connectionURL}" userId="${jdbc.userId}" password="${jdbc.password}"> </jdbcConnection> <!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制--> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类 targetPackage 指定生成的model生成所在的包名 targetProject 指定在该项目下所在的路径 --> <javaModelGenerator targetPackage="com.slx.zsxt.model" targetProject="src/main/java"> <!-- 是否允许子包,即targetPackage.schemaName.tableName --> <property name="enableSubPackages" value="false"/> <!-- 是否对model添加 构造函数 --> <property name="constructorBased" value="true"/> <!-- 是否对类CHAR类型的列的数据进行trim操作 --> <property name="trimStrings" value="true"/> <!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 --> <property name="immutable" value="false"/> </javaModelGenerator> <!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 --> <sqlMapGenerator targetPackage="com.slx.zsxt.mapper" targetProject="src/main/java"> <property name="enableSubPackages" value="false"/> </sqlMapGenerator> <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码 type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 --> <javaClientGenerator targetPackage="com.slx.zsxt.dao" targetProject="src/main/java" type="XMLMAPPER"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <table tableName="reguser" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table tableName="adminuser" domainObjectName="Admin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table tableName="configinfo" domainObjectName="Confinfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table tableName="grade" domainObjectName="Grade" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table tableName="gradelog" domainObjectName="Gradelog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table tableName="reginfo" domainObjectName="Reginfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> 

转载于:https://www.cnblogs.com/weizhxa/p/11021913.html

如何在idea中使用Mybatis-generator插件快速生成代码相关推荐

  1. Myeclipse中安装mybatis generator插件有两种方式,一种是在线安装,一种是离线安装。

    一.在线安装:Help------>MyEclipse Configuration Center,选择add site,填入MyBatis generator插件的地址: http://myba ...

  2. idea mybaits逆向工程_IDEA 中集成 MyBatis Generator 组件逆向生成工程

    IDEA 逆向 MyBatis 工程时,不像支持 Hibernate 那样有自带插件,需要集成第三方的 MyBatis Generator. MyBatis Generator的详细介绍 http:/ ...

  3. IDEA插件系列(69):Current date generator插件——快速生成当前日期

    1.插件介绍 Current date generator插件. 日期生成器. 生成不同格式的当前日期. 默认格式为:yyyy-MM-dd'T'HH:mm:ssXXX.进入"日期生成器&qu ...

  4. MBG真香 Spring Boot集成Mybatis Generator插件

    Mybatis中文官网对mybatis-generator的介绍:http://www.mybatis.cn/archives/885.html Mybatis官网对mybatis-generator ...

  5. Springboot—mysql+mybatis+generator插件

    1.idea-generatorConfig.xml <?xml version="1.0" encoding="UTF-8"?> <!DOC ...

  6. MyEclipse添加Mybatis generator插件

    进入MyEclipse Configuration Center选择add site,填入MyBatis generator插件的地址:http://mybatis.googlecode.com/sv ...

  7. Android中使用AbstractProcessor在编译时生成代码

    Android中使用AbstractProcessor在编译时生成代码 发现这边不错的文章,忍不住转了过来,转自: http://blog.csdn.net/industriously/article ...

  8. Eclipse安装Hibernate插件快速生成配置文件

    Eclipse安装Hibernate插件快速生成配置文件 插件链接: http://pan.baidu.com/s/1mi3KVtI 密码: kmjg 1.安装插件: 1.在eclipse顶部窗口he ...

  9. idea mybatis generator插件_在idea中使用mybatis generator逆向工程生成代码

    用maven工具生成mybatis的代码和映射文件. 1.配置pom.xml文件 在pom.xml下添加插件如下: <build> <finalName>zsxt</fi ...

最新文章

  1. Windows Server 2008域中组的成员关系
  2. 加入域应具备的权限讨论
  3. grep查询不到中文 或 Binary file xx matches
  4. 常用公有云接入——谷歌
  5. 多线程写mysql数据库_多线程读写mysql数据库
  6. c语言api_用C语言来拓展python的功能
  7. 钉钉下载与安装过程 适用于windows系统 20200718
  8. python 识别登陆验证码图片(完整代码)_python 识别登录验证码图片功能的实现代码(完整代码)...
  9. (13)ISE14.7bit文件生成mcs文件(FPGA不积跬步101)
  10. silverlight 自定义资源整理(待后续补充)
  11. openresty 前端开发入门三之JSON篇
  12. Python利用Graphviz画图
  13. bp神经网络数据预测实例,bp神经网络预测数据
  14. NRF24L01详解
  15. 微信小程序支付---详解(python)
  16. JavaScript基础知识总结(1)
  17. Linux实验13_进程管理及任务计划.docx
  18. 征服面试官的50道Redis高频通关面试题
  19. ibm x服务器硬盘检测,IBM System x 服务器自带RAID1的故障恢复
  20. 偶遇Chrome浏览器“喔唷,崩溃啦”,错误代码(STATUS_STACK_BUFFER_OVERRUN)

热门文章

  1. linux svn 指定端口号,linux(Ubuntu)搭建Subversion服务器+修改svn端口号
  2. jmeter修改redis_jmeter如何访问redis服务缓存
  3. 华润置地php面试题_长春华润置地崑崙御,以至臻匠心,成就城市典范
  4. 网络编程与分层协议设计:基于linux平台实现,网络编程与分层协议设计:基于Linux平台实现...
  5. java static方法
  6. 马匹赛跑java_java模拟龟兔赛跑
  7. C++ 读入一行字符串
  8. Android Sdk 安装配置
  9. SpringBoot页面出现 Whitelabel Error Page
  10. 判断三角形是否是直角三角形