mybatis-generator生成通用mapper中文乱码解决
2023-03-14 10:24:37 时间
<?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>
<property name="javaFileEncoding" value="UTF-8"/>
<!-- 数据库连接信息 --> <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生成代码即可,发现没有中文乱码了。
相关文章
- redis 执行命令报错:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to pers
- How to access the HttpRequest object in Django forms( Django view 给 forms 传递数据)
- 加密货币仍在争论它应该在多大程度上关注隐私
- pandas read_csv、read_excel 以文本形式读取零开头的纯数字字符
- FiddlerDecryption(fiddler Inspectors 插件开发)
- pandas read_csv、read_excel 填充合并的单元格
- django import_export 个性化导出 model 里的 字段含有 choice 的值
- docker-compose 安装部署 mysql
- docker-compose 安装部署 redis
- redis 模糊匹配和批量删除
- 【每周小结】2023-Week3
- JSONP原理及promise封装
- Docker 下快速搭建 MySQL 和 Redis
- 图文结合带你搞懂InnoDB MVCC
- 浅谈 MySQL 新的身份验证插件 caching_sha2_password
- MySQL 聚合函数初探
- MySQL科学计数法展示解惑
- Debezium的增量快照
- 图文结合带你搞懂MySQL日志之Redo Log(重做日志)
- 深入聊聊MySQL直方图的应用