异常如下:
CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
做了个demo项目运行dockerfile打包镜像容器并运行抛出了如上异常
本地可以连接项目并启动
打包镜像和容器运行后 docker logs 容器id时提示如上异常
解决如下:
application.yml数据源配置 注意useSSL=false配置不能丢失
url: jdbc:mysql://192.168.1.10:3306/skywalking_service?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
在创建并运行Docker容器时,遇到CommunicationsException,导致无法连接到MySQL服务器。问题根源在于缺少了`useSSL=false`的数据源配置。通过在application.yml中正确配置数据库连接URL,例如:jdbc:mysql://192.168.1.10:3306/skywalking_service?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true,解决了通信异常,确保了本地与Docker容器内的应用程序能正常连接和使用MySQL服务。
567

被折叠的 条评论
为什么被折叠?



