问答详情
源自:4-8 DAO层单元测试编码和问题排查(上)

求大神解答,报错

Caused by: 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.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 16; 文档根元素 "configuration" 必须匹配 DOCTYPE 根 "mapper"。



Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 16; 文档根元素 "configuration" 必须匹配 DOCTYPE 根 "mapper"。


Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 16; 文档根元素 "configuration" 必须匹配 DOCTYPE 根 "mapper"。

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-2.5.xsd">

<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

<property name="driverClass" value="${jdbc.driverClass}"></property>

<property name="jdbcUrl" value="${jdbc.url}"></property>

<property name="user" value="${jdbc.username}"></property>

<property name="password" value="${jdbc.password}"></property>

<!-- c3p0连接池的私有属性 -->

<property name="maxPoolSize" value="30"></property>

<property name="minPoolSize" value="10"></property>

<!-- 关闭连接后不自动commit -->

<property name="autoCommitOnClose" value="false"></property>

<!-- 获取连接超时时间 -->

<property name="checkoutTimeout" value="1000"></property>

<!-- 当获取连接失败重试次数 -->

<property name="acquireRetryAttempts" value="2"></property>

</bean>


<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<property name="dataSource" ref="dataSource"></property>

<property name="configLocation" value="classpath:mybatis-config.xml"></property>

<property name="typeAliasesPackage" value="org.seckill.entity"></property>

<property name="mapperLocations" value="classpath:mapper/*.xml"></property>

</bean>


<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>

<property name="basePackage" value="org.seckill.dao"></property>

</bean>


</beans> 


提问者:宝慕林0518688 2017-06-15 16:11

个回答