org.xml.sax.SAXParseException: The content of element type "configuration" must match

前端之家收集整理的这篇文章主要介绍了org.xml.sax.SAXParseException: The content of element type "configuration" must match前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在mybatis的配置文件中新增加<databaseIdProvider type="VENDOR">节点后,原来正确的配置文件立即变得不可用了,出现的错误信息如下:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error building sqlSession.
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
	at org.apache.ibatis.session.sqlSessionFactoryBuilder.build(sqlSessionFactoryBuilder.java:79)
	at org.apache.ibatis.session.sqlSessionFactoryBuilder.build(sqlSessionFactoryBuilder.java:63)
	at testMybatis.Test.main(Test.java:20)
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,mappers?)".
	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:253)
	at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:122)
	at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:72)
	at org.apache.ibatis.session.sqlSessionFactoryBuilder.build(sqlSessionFactoryBuilder.java:76)
	... 2 more
Caused by: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,mappers?)".
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2017)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:901)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
	... 5 more


异常中的信息已经描述得比较清楚了:

org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,mappers?)".

其实就是mybatis配置文件中的各节点必须按照properties?,mappers?

顺序排列。如果把databaseIdProvider写到mappers后边,立即就抛出如上异常。将其移动到mappers前边后,mybatis就能正确解析节点了。

这坑爹的mybatis...

原文链接:https://www.f2er.com/xml/298022.html

猜你在找的XML相关文章