个人在项目搭建过程中,配置Mybatis配置文件时,出现错误:在UserMapper.xml头文件出现 "Referenced file contains errors(file:/D:/config/mybatis-3-mapper.dtd). For more information, right click on the message in the Problems View and select "Show Details..." 的问题????
对于这个问题,出现问题的mapper.xml文件的头文件是
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
在这里请看清楚的是:是mybatis-3-mapper.dtd头文件,如图片1所示。
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
图片一
解决方法是:可能是由于我自己使用的Mybatis的config配置文件—— mybatis-3-mapper.dtd文件版本较低,当我更换一个高版本的mybatis-3-mapper.dtd文件后,在Eclipse中重新加载mybatis-3-mapper.dtd文件,在通过"Project ---> clear"项目后,错误消失,问题得以解决。
如图片二、图片三、图片四所示。
在本地磁盘中将高版本的mybatis-3-mapper.dtd放到固定的位置后,在Eclipse中重新加载mybatis-3-mapper.dtd文件。
//========mybatis-3-config.dtd头文件出错========
mybatis的配置文件报错
The errors below were detected when validating the file "mybatis-3-config.dtd" via the file "mybatis-config.xml". In most cases these errors can be detected by validating "mybatis-3-config.dtd" directly. However it is possible that errors will only occur when mybatis-3-config.dtd is validated in the context of mybatis-config.xml.
配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
将
"http://mybatis.org/dtd/mybatis-3-config.dtd">
修改为
"http://www.mybatis.org/dtd/mybatis-3-config.dtd">
备注:关于mybatis-3-config.dtd头文件出错的问题以及解决方案,是我个人在网上查找而来,我个人也将其放入本篇博客中。对于其提供的解决方案到底正不正确,我个人不得而知。
Mybatis框架中,关于mybatis-3-mapper.dtd、mybatis-3-config.dtd文件下载地址:mybatis框架的2个DTD文件