bug解决:org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

半腔热情 提交于 2020-02-06 08:02:36
  1. Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。
  2. at [图片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
  3. at [图片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
  4. at [图片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  5. at [图片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  6. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
  7. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source)
  8. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
  9. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)
  10. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
  11. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
  12. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  13. at [图片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  14. at [图片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  15. at [图片]com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
  16. at [图片]com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
  17. at [图片]com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
  18. at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
  19. ... 31 more

这两天在整合mybatis项目时,遇到了这个问题,后来查了资料才发现原来如此。

问题:xml文件的第一行不允许有空格或是空行

问题解决 :

查看了项目的所有xml文件,发现spring-mybatis.xml 配置文件的首行是空的,删除该行即可(确保xml的第一句<?xml version="1.0" encoding="UTF-8"?>之前没有空格或空行即可)

  1. Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。
  2. at [图片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
  3. at [图片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
  4. at [图片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  5. at [图片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  6. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
  7. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source)
  8. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
  9. at [图片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)
  10. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
  11. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
  12. at [图片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  13. at [图片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  14. at [图片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  15. at [图片]com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
  16. at [图片]com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
  17. at [图片]com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
  18. at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
  19. ... 31 more
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!