<plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <configuration> <!--配置文件的位置--> <overwrite>true</overwrite> <verbose>true</verbose> </configuration></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="Maven中央仓库MySQL依赖中jar包的位置"/> <context id="context1" targetRuntime="项目名"> <commentGenerator> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 数据库链接URL、用户名、密码 --> <!--<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/blog" userId="root" password="root"> --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true" userId="数据库用户名" password="数据库密码"> </jdbcConnection> <!-- 生成模型的包名和位置 --> <javaModelGenerator targetPackage="实体类包的全路径名" targetProject="src/main/java"> <!--<property name="enableSubPackages" value="true"/>--> <!--<property name="trimStrings" value="true"/>--> </javaModelGenerator> <!-- 生成的映射文件包名和位置 --> <sqlMapGenerator targetPackage="映射包的全路径名" targetProject="src/main/java"> <!--<property name="enableSubPackages" value="true"/>--> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="dao包的全路径名" targetProject="src/main/java"> <property name="enableSubPackages" value="true"/> </javaClientGenerator><table schema="数据库表名" tableName="数据库表名" domainObjectName="设置实体类名"></table>
如果有多个表,以上类推 </context></generatorConfiguration>