idea整合spring-mybatis出现:org.xml.sax.SAXParseException; 前言中不允许有内容的问题

idea下整合spring-mybatis出现 Cause: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 55; 前言中不允许有内容的问题

跟着网上的教程整合了一遍spring和mybatis,核心内容与教程的内容一模一样(前后对了几遍)但是使用单元测试的时候总是出现上述的问题。
在这里插入图片描述总体就是说解析xml文件的时候出现错误

文件的编码格式问题

在网上找了一些解决前言中不允许有内容的一些方法,
例如查看文件的编码格式,另存为无BOM的utf-8编码格式,
为此我还专门下了一个Notepad++,一看发现我的appicationContext.xml的文件格式没有错

web.xml读取spring 的配置文件

网上还有一种解决方法就是使用web.xml来读取spring的配置文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:appicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

但是这个还不是解决的问题,还是出现了错误

最后检查每一个相关的文件,重头到尾的检查了一遍,还是没有发现问题,然后我再看抛出的错误信息,发现了下面这个

'file [D:\java web\IntelliJ IDEA 2017.3.2\spacework\ssm\out\production\ssm\com\java\mapper\UserMapper.xml]';

看了一遍UserMapper.xml文件后发现文件上面多了一个字母
在这里插入图片描述
就是因为多了这个s,才导致上面的问题

最后正常的输出结果:

log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
User{id=1, username='王五', birthday=null, sex='2', address='null'}

Process finished with exit code 0

这个事情让我明白了真的不能粗心大意,一个小字母浪费了我大半天的时间