mybatis generator使用(基于maven)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis generator使用(基于maven)相关的知识,希望对你有一定的参考价值。
1、添加maven依赖
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.4</version>
</dependency>
2、添加插件
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.4</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
3、generator.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>
<classPathEntry
location="/Users/Torres/.m2/repository/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar"/>
<context id="MysqlTables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://********:3306/extmail?characterEncoding=utf8"
userId="*****" password="****">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.enniu.cloud.services.billcredit.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
<property name="useActualColumnNames" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="mapper"
targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.enniu.cloud.services.billcredit.dao.mapper"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="T_UserCardExt" domainObjectName="UserCardExt" enableCountByExample="false"
enableUpdateByExample="true" enableDeleteByExample="false" enableSelectByExample="true"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
4、进入项目,执行命令:mvn mybatis-generator:generate
[email protected] server$ mvn mybatis-generator:generate
以上是关于mybatis generator使用(基于maven)的主要内容,如果未能解决你的问题,请参考以下文章
手把手教学基于Maven构建方式使用Mybatis generator自动生成
手把手教学基于Maven构建方式使用Mybatis generator自动生成
手把手教学基于Maven构建方式使用Mybatis generator自动生成