Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
2017-04-26 18:23
666 查看
创建Maven项目(略过)
在pom文件中添加
在maven项目下的src/main/resources 目录下建立名为 generatorConfig.xml的配置文件,作为mybatis-generator-maven-plugin 插件的执行目标,模板如下:
文件目录结构:
4. 在Intellij IDEA添加一个“Run运行”选项,使用maven运行mybatis-generator-maven-plugin插件
如果添加成功,则会在run 选项中有“generator” 选项,如下:
点击运行,如果执行成功,最后会看到控制台的
在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 选项,会把具体的详细错误信息打印出来的,根据错误信息修改即可
相关文章推荐
- 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代码
- 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 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码