三个宝藏,呵呵
java.io.IOException: Could not find resource mapping/UserMapper.xml
这个异常是最爆炸的,明明创建了UserMapper.xml文件,路径也写的是对的,居然给我报了一个找不到源文件的异常。
这是因为
IDEA的Maven是不会编译src的java目录的xml文件
所以要在pom里自己配!WTF!!!
配置方法如下:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
org.xml.sax.SAXParseException 文档根元素 “mapper” 必须匹配 DOCTYPE 根 “configuration”
XML文档里 DOCTYPE 这个东西后面跟的东西要和根标签匹配
复制粘贴的时候注意
Type interface com.mybatis.mapper.UserMapper is not known to the MapperRegistry.
UserMapper接口没有被注册,那肯定就是xml配置文件的问题,找到路径名,查错即可