求大神指点,SSM项目 dao层测试出错,不知道问题在哪里

基于ssm框架开发的项目,dao层测试时发生错误,求大神帮忙指引解决,说不清楚的可以加我q远程协助.

```五月 10, 2018 12:11:50 下午 org.springframework.context.support.GenericApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\MyEclipse\MyClass\o2o Maven Webapp\target\classes\mapper\AreaDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 47; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。
五月 10, 2018 12:11:50 下午 org.springframework.test.context.TestContextManager prepareTestInstance
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@77b52d12] to prepare test instance [com.imooc.o2o.dao.AreaDaoTest@4de4b452]
java.lang.IllegalStateException: Failed to load ApplicationContext

spring-dao.xml配置如下

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">
    <!-- 配置整合mybatis过程 -->
    <!-- 1.配置数据库相关参数properties的属性:${url} -->
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <!-- 2.数据库连接池 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <!-- 配置连接池属性 -->
        <property name="driverClass" value="${jdbc.driver}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />

        <!-- c3p0连接池的私有属性 -->
        <property name="maxPoolSize" value="30" />
        <property name="minPoolSize" value="10" />
        <!-- 关闭连接后不自动commit -->
        <property name="autoCommitOnClose" value="false" />
        <!-- 获取连接超时时间 -->
        <property name="checkoutTimeout" value="10000" />
        <!-- 当获取连接失败重试次数 -->
        <property name="acquireRetryAttempts" value="2" />
    </bean>

    <!-- 3.配置SqlSessionFactory对象 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 注入数据库连接池 -->
        <property name="dataSource" ref="dataSource" />
        <!-- 配置MyBaties全局配置文件:mybatis-config.xml -->
        <property name="configLocation" value="classpath:mybatis-config.xml" />
        <!-- 扫描entity包 使用别名 -->
        <property name="typeAliasesPackage" value="com.imooc.o2o.entity" />
        <!-- 扫描sql配置文件:mapper需要的xml文件 -->
        <property name="mapperLocations" value="classpath:mapper/*.xml" />
    </bean>

    <!-- 4.配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!-- 注入sqlSessionFactory -->
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
        <!-- 给出需要扫描Dao接口包 -->
        <property name="basePackage" value="com.imooc.o2o.dao" />
    </bean>
</beans>

贴一个链接,你可以参考一下, https://www.cnblogs.com/tanglie/p/6672225.html

可能是mybatis-spring版本不支持当前mybatis版本跟Spring版本。

可能有两个原因 参考
https://blog.csdn.net/ahou2468/article/details/65447816?locationNum=11&fps=1

这个可能是版本不兼容吧

你的web.xml会不会没有引入这个文件?

你的dao和映射文件.xml需要放在同一个文件目录里面,否则映射不到。

AreaDao.xml 你检查一下这个文件,上面以经说了 行数 和 列数。 lineNumber: 2; columnNumber: 47; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。

发一下你的jar包版本,和web.xml配置

Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 47; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。

这已经给出了原因, xml 文档,用sax 解析时出错!
xml 文档写的不对, mapper.xml 文件不对嘛

把你的mapper文件, 找个xml校验器, 验证下。

Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 47; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。

这已经给出了原因, xml 文档,用sax 解析时出错!
xml 文档写的不对, mapper.xml 文件不对嘛

把你的mapper文件, 找个xml校验器, 验证下。

把你的mapper文件, 找个xml校验器, 验证下

spring boto

https://www.cnblogs.com/tanglie/p/6672225.html