為什么我的錯誤是這樣的 文件是utf8 不是bom
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.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [maper]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. ?Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允許有內容。
2017-07-14
我的問題是應為 spring 配置mapper 寫錯了 少寫了/*.xml
2017-07-13
解決方法:
1、確保xml的第一句<?xml version="1.0" encoding="UTF-8"?>之前沒有空格。
2、復制網上的xml文件的時候,建議這一句<?xml version="1.0" encoding="UTF-8"?>不要復制,保留生成文件的時候生成的這句代碼<?xml version="1.0" encoding="UTF-8"?>,這樣就能避免這種bug出現。