mybatis generatorConfiguration配置如下:
<?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>
<!-- mysql-connector jar包替换为本地的jar -->
<classPathEntry
location="C:\xxx\repository\mysql\mysql-connector-java\5.1.42\mysql-connector-java-5.1.42.jar" />
<context id="context1" targetRuntime="MyBatis3" defaultModelType="flat">
<!--覆盖生成XML文件-->
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
<!-- 不生成注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://ip:port/db-name?tinyInt1isBit=false"
userId="db-username" password="xxx" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="com.xxx.xxxx.dal.entity"
targetProject="src/main/java" />
<sqlMapGenerator targetPackage="com.xxx.xxxx.dal.mapper"
targetProject="src/main/resources" />
<!-- 生成xml文件 -->
<javaClientGenerator targetPackage="com.xxx.xxxx.dal.mapper"
targetProject="src/main/java" type="XMLMAPPER" />
<!-- 生成annotated -->
<!--<javaClientGenerator targetPackage="com.xxx.xxxx.dal.mapper" targetProject="src/main/java"
type="ANNOTATEDMAPPER"/> -->
<!-- XML和注解的混合形式,(上面这种情况中的)SqlProvider注解方法会被XML替代 -->
<!-- <javaClientGenerator targetPackage="com.xxx.xxxx.dal.mapper"
targetProject="src/main/java" type="MIXEDMAPPER"/> -->
<!-- 待生成的表 -->
<table tableName="user_info" domainObjectName="UserInfo"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
mybatis-generator生成器:
Goals:mybatis-generator:generate
Profiles:
运行生成对应的xml和对象类