Type interface com.kuang.dao.UserDao is not known to the MapperRegistry.
问题分析:mybatis-config.xml中没有注册所需要的mapper.xml。
解决方案:在mybatis-config.xml文件中添加以下代码:
<mappers>
<mapper resource="com/kuang/dao/UserMapper.xml"/> //对应的xml文件
</mappers>
Could not find resource mybatis-config.xml
问题分析:虽然已经配置好了mybatis-config.xml,而且已经注册,但是编译还是出现问题,主要是因为maven的约定大于配置,自己写的配置文件无法被导出,(可以查找target.classes里面是否有相应的xml文件来判断)
解决方法:在主工程的pom.xml文件(最好本工程的pom.xml文件)也添加以下代码:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
java.io.IOException: Could not find resource com/kuang/dao/UserMapper.xml
问题解析:很显然是UserMapper.xml配置文件导入失败,可以直接检查配置文件的内容,原内容如下:
<property name="url" value="${jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8}"/>
<property name="username" value="${root}"/>
<property name="password" value="${123456}"/>
检查可以看出配置时直接下载的官方文档,有些东西没有删除干净,导致配置失败。
解决方法:
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
4.Path does not chain with any of the trust anchors
问题分析:useSSL问题
解决方案:useSSL=false;