1.pom.xml
<!--逆向工程-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<!-- 配置generatorConfig.xml的路径和名称 -->
<configuration>
<configurationFile>
${basedir}\src\main\resources\generatorConfig.xml
</configurationFile>
</configuration>
<!-- 配置generator运行插件,使maven执行generator -->
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
2.新建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>
<!-- !!!! Driver Class Path !!!! -->
<classPathEntry location="C:\Users\admin\.m2\repository\mysql\mysql-connector-java\5.1.43\mysql-connector-java-5.1.43.jar"/>
<context id="context" targetRuntime="MyBatis3">
<!-- 是否去除注释-->
<commentGenerator>
<property name="suppressAllComments" value="true"/>
<property name="suppressDate" value="true"/>
</commentGenerator>
<!-- !!!! Database Configurations !!!! -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/map?characterEncoding=UTF8&useSSL=false"
userId="root" password="root"/>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- !!!! Model Configurations !!!! -->
<javaModelGenerator targetPackage="com.how2java.pojo" targetProject="src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false"/>
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- !!!! Mapper XML Configurations !!!! -->
<sqlMapGenerator targetPackage="com.how2java.mapping" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- !!!! Mapper Interface Configurations !!!! -->
<javaClientGenerator targetPackage="com.how2java.mapper" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- !!!! Table Configurations !!!! -->
<!-- 指定数据库表 -->
<!--<table tableName="admin" domainObjectName="Admin"></table>-->
<!--<table tableName="area" domainObjectName="Area"></table>-->
<!--<table tableName="business" domainObjectName="Business"></table>-->
<!--<table tableName="label" domainObjectName="Label"></table>-->
<!--<table tableName="payment" domainObjectName="Payment"></table>-->
<!--<table tableName="seedetails" domainObjectName="Seedetails"></table>-->
<!--<table tableName="send_message" domainObjectName="SendMessage"></table>-->
<!--<table tableName="store" domainObjectName="Store"></table>-->
<!--<table tableName="store_news" domainObjectName="StoreNews"></table>-->
<!--<!–<table tableName="store_news_category" domainObjectName=""></table>–>-->
<!--<table tableName="store_search_history" domainObjectName="StoreSearchHistory"></table>-->
<table tableName="user" domainObjectName="User"></table>
<!--<table tableName="user_search_history" domainObjectName="UserSearchHistory"></table>-->
<!--<table tableName="salesman" domainObjectName="SalesMan"></table>-->
<!--<table tableName="vrphoto" domainObjectName="Vrphoto"></table>-->
</context>
</generatorConfiguration>
3.运行