【Mybatis疑难杂症】找不到路径和mysql版本一系列问题(精准图文)

1.Could not find resource xxx.xml

这个问题我尝试了很多解决办法
1.src/java下的xml不会被编译,然后到pom.xml的build标签里添加resources(我这边没用)

<resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
    </resources>

2.将xxx.xml放到java目录下,(还是没用)
3.路径用/分隔无需多说(但我直接改成了文件名)
在这里插入图片描述

4.将xxx.xml放到resources的根目录下,(终于解决了,没想到最后是这样解决的)
之前是这样的
在这里插入图片描述
后来是这样的
在这里插入图片描述

2.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server

这个大概率是因为pom.xml中配置的mysql-connector-java版本不对
1.查看安装的MySQL版本(我这里是8.0.13)

在这里插入图片描述
2.在pom.xml中添加mysql的dependence(版本同样为8.0.13)
在这里插入图片描述
这个问题解决后,往往会诞生下一个问题

3.mysql版本超过5.5.45就要设置ssl

错误信息:

.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 verifica

"jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC&amp;useSSL=false"

useSSL=false 一定要加
serverTimezone=UTC 可依情况而定

猜你喜欢

转载自blog.csdn.net/weixin_43046082/article/details/88900191