在spring boot 整合mybatis和log4j2时出现的问题

网上找了很久没有解决,最后找到原因

问题出在mybatis配置里

mybatis:
  typeAliasesPackage: com.example.demo.model
  mapperLocations: classpath:**/*.xml

修改为

mybatis:
  typeAliasesPackage: com.example.demo.model
  mapperLocations: classpath:com/example/demo/xml/*.xml

下面贴上项目结构

org.xml.sax.SAXParseException: 文档根元素 "Configuration" 必须匹配 DOCTYPE 根 "null"

 因为在原先的mapperLocations属性中配置的是classpath:**/*.xml

这样会导致程序认为resources下的log4j2.xml也是mapper文件,然后mybatis在处理它的时候就会报错

相关文章: