1、在项目的src/main/resources新建MyBatis-Generator的配置文件,如命名为mybatis-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>
<!--targetRuntime="MyBatis3Simple":生成简单版的CRUD;MyBatis3:豪华版 -->
<context id="MyBatisGenerator" targetRuntime="MyBatis3">
<!-- 生成的实体Bean,将实现Serializable -->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 ; false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- jdbcConnection:连接数据库 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/spring" userId=