栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

mybatis-generator报错Communications link failure

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mybatis-generator报错Communications link failure

踩坑现场 控制台错误日志
[INFO] --- mybatis-generator-maven-plugin:1.3.7:generate (default-cli) @ myproject ---
[INFO] Connecting to the Database
Wed Jun 08 17:28:08 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.571 s
[INFO] Finished at: 2022-06-08T17:28:08+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.7:generate (default-cli) on project myproject: Communications link failure
[ERROR] 
[ERROR] The last packet successfully received from the server was 536 milliseconds ago.  The last packet sent successfully to the server was 518 milliseconds ago.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
generator配置

  
执行命令
mvn mybatis-generator:generate -Dmybatis.generator.configurationFile=src/test/resources/generatorConfig.xml -Dmybatis.generator.overwrite=true
问题排查 网络排查

网络问题那么久排查网络咯,检查网络与端口是否互通,可以使用telnet命令检查,如果没有报错则说明host与端口服务都是正常的

telnet host port
账号检查

host/port/账号/密码检查,可以本地mysql尝试连接,根据响应提示检查是否权限问题?账号密码错误问题

mysql -hmyhost -umyuser -pmypwd -Pmyport
版本检查

查看服务器版本:5.7x

show global variables like 'version';

查看驱动版本:配置中有指定=mysql-connector-java-5.1.47

问题原因

网络/账号/版本均正常,但依然报错网络问题,查询资料结论为版本问题,当版本8.x客户端连接版本5.x的服务端会有此类问题,检查发现本地mysql客户端版本确实是8.x,同样说明mybatis生成器连接服务端是基于本地客户端完成的

解决方案

其实错误日志中的warn已经给出了提示,连接url增加useSSL=false即可,或者提供ssl证书

jdbc:mysql://myhost:3306/mydb?useUnicode=true&useSSL=false
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/970777.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号