①pom.xml导入依赖包时注意mysql的版本 使用版本过低会报错(可以使用8.0.11)

在这里插入图片描述
在这里插入图片描述

② 记得在pom.xml添上下面的语句(如果不指明版本就容易出现版本不匹配的问题,可能导致编译不通过的问题。)
<properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
③ 在mybatis-config.xml中,将驱动程序类改为:“com.mysql.cj.jdbc.Driver”.(com.mysql.jdbc.Driver是老版的加载类,不推荐使用)
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
④ 修改 useSSL
useSSL=false
⑤ 添加时区
serverTimezone=Asia/Shanghai
⑥ 用 &amp 连接
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=Asia/Shanghai"/>

问题解决:
①org.apache.ibatis.exceptions.PersistenceException: https://blog.csdn.net/weixin_46822367/article/details/114900536?spm=1001.2014.3001.5501.
②org.apache.ibatis.binding.BindingException: https://blog.csdn.net/weixin_46822367/article/details/114900015?spm=1001.2014.3001.5501.
③java.lang.ExceptionInInitializerError: https://blog.csdn.net/weixin_46822367/article/details/114897648?spm=1001.2014.3001.5501.

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐