mybatis configuration的内容必须匹配问题

问题:今天在写mybatis plugin插件的时候碰到如下错误:

org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 17; 元素类型为 "configuration" 的内容必须匹配 "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)"。
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:82)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:66)
分析:解析xml的plugins出现问题。

原因:Mybatis3.X 的版本使用的 dtd 作为 XML 的格式校验文档。 而在 XML 规范中,dtd 是有严格的顺序的,在报错的异常中已经列出了对应的顺序,所以必须进行严格匹配:plugins必须写在mappers之前。

	<plugins>
		<plugin interceptor="com.steven.interceptor.PageInterceptor">
			<property name="databaseType" value="mysql"/>
		</plugin>
	</plugins>

    <mappers>
        <mapper resource="mapper/Order.xml"/>
        <mapper resource="mapper/Workflow.xml"/>
        <mapper resource="mapper/PacificLog.xml"/>
        <mapper resource="mapper/OrderMapping.xml"/>
        <mapper resource="mapper/PacificAgreementInstance.xml"/>
        <mapper resource="mapper/PlatformRelation.xml"/>
        <mapper resource="mapper/PlatformRelationAttributes.xml"/>
    </mappers>
参考:http://www.cnblogs.com/myssh/p/5404936.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值