<?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="C:\Users\Administrator\Desktop\tools\generator\mysql-connector-java-5.1.34.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper" />
<!-- caseSensitive默认false,当数据库表名区分大小写时,可以将该属性设置为true -->
<!-- <property name="caseSensitive" value="true" /> -->
</plugin>
<!-- 阻止生成自动注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true"/>
</commentGenerator>
<!-- 数据库连接信息 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/webchat" userId="root" password="root">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="webchat.model" targetProject="D:\workspace\webchat\src\main\java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="webchat.mapping" targetProject="D:\workspace\webchat\src\main\java">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="webchat.dao" targetProject="D:\workspace\webchat\src\main\java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="t_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="t_group" domainObjectName="Group" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="group_user" domainObjectName="groupUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="group_message" domainObjectName="groupMessage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="friend_type" domainObjectName="friendType" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="friend_message" domainObjectName="friendMessage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
<table tableName="friend" domainObjectName="Friend" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
<generatedKey column="id" sqlStatement="Mysql"/>
</table>
</context>
</generatorConfiguration>
首先检查你的 generator.xml 要有 <property name="javaFileEncoding" value="UTF-8"/>
然后检查工程是否为utf-8编码!
最后打开你的exlipse.ini 文件,最末尾加上 -Dfile.encoding=UTF-8
重启eclipse,配置maven生成代码即可解决
参考博客
https://blog.csdn.net/jkxqj/article/details/54313149
https://my.oschina.net/lin546/blog/1632809