在学习Mybatis的mapper接口动态代理使用JDK代理时,遇到的报错:
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in UserMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 55; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。
解决方式:
即加入下面的代码:
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
加入后变成:
最终测试成功。