Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
来源:互联网 发布:二级域名 不同端口 编辑:程序博客网 时间:2024/06/06 02:19
- 创建Maven项目(略过)
- 在pom文件中添加
<build> <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项目下的src/main/resources 目录下建立名为 generatorConfig.xml的配置文件,作为mybatis-generator-maven-plugin 插件的执行目标,模板如下:
<?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="./sql/mysql-connector-java-5.1.30.jar" /> <context id="context1" targetRuntime="MyBatis3" > <plugin type="org.mybatis.generator.plugins.SerializablePlugin" /> <!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> --> <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" /> <plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin"> <!--<property name="searchString" value="Example$" /> <property name="replaceString" value="Conditions" />--> </plugin> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://182.254.137.242:3306/finger_shop?useUnicode=true&characterEncoding=utf8" userId="zjdy" password="finger.123456" /> <javaModelGenerator targetPackage="com.zxy.schedule.model" targetProject="../myweb/src/main/java" /> <sqlMapGenerator targetPackage="com.zxy.mapper" targetProject="../myweb/src/main/resources/" /> <javaClientGenerator targetPackage="com.zxy.schedule.mapper" targetProject="../myweb/src/main/java" type="XMLMAPPER" /> <table tableName="tbOrder" domainObjectName="OrderInfo"> <generatedKey column="id" sqlStatement="JDBC" /> <columnOverride column="billNumber" javaType="String" /> <columnOverride column="buildDate" javaType="String" /> <columnOverride column="customer" javaType="String" /> <columnOverride column="goodsName" javaType="String" /> <columnOverride column="amount" javaType="float" /> <columnOverride column="saleMoney" javaType="float" /> </table> </context></generatorConfiguration>
文件目录结构:
4. 在Intellij IDEA添加一个“Run运行”选项,使用maven运行mybatis-generator-maven-plugin插件
如果添加成功,则会在run 选项中有“generator” 选项,如下:
点击运行,如果执行成功,最后会看到控制台的BUILD SUCCESS
,则大功告成,如果有错误的话,由于添加了-e 选项,会把具体的详细错误信息打印出来的,根据错误信息修改即可
0 0
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA中使用Mybatis-generator自动生成Mtbatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- 日期格式yyyy-MM-dd和YYYY-MM-dd有什么区别?
- eclipse 新建类自动生成注释信息
- Android中Activity四种启动方式
- Nginx开发一个简单的HTTP过滤模块
- 轻松搭建ES6开发环境
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- codeforces B. Mike and strings
- 设置基本运行时间与内存分配
- Linux内核漏洞利用入门
- 递归和非递归实现归并排序
- java生成图片验证码
- SystemServer的产生和启动
- 用verilog语言设计一个2s的呼吸灯
- Java泛型浅析