- Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允許有匹配 "[xX][mM][lL]" 的處理指令目標。
- at [圖片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
- at [圖片]com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
- at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
- ... 31 more
這兩天在整合mybatis項目時,遇到了這個問題,後來查了資料才發現原來如此。
問題:xml文件的第一行不允許有空格或是空行
問題解決 :
查看了項目的所有xml文件,發現spring-mybatis.xml 配置文件的首行是空的,刪除該行即可(確保xml的第一句<?xml version="1.0" encoding="UTF-8"?>之前沒有空格或空行即可)