spring-mybatis整合小异常积累篇

异常一:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。

 百度了好多篇解决方案,都说是xml的格式有问题说,即生成的xml文件带bom格式,然后感觉解决方法有点复杂,于是又重新看了下配置文件里的代码,发现是自己的路径有问题,如下图:

然后修改成正确的文件路径,如下图:

然后然后问题就解决了,也能查询到用户信息了。与xml文件格式无关。

异常二:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 70 in XML document from class path resource [spring/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 70; columnNumber: 9; cvc-complex-type.2.3: 元素 'beans' 必须不含字符 [子级], 因为该类型的内容类型为“仅元素”。

   一开始以为是哪里配置有问题,后来查了很久,原来是有个注释没写全,就出现了以上错误。加上注释之后就能运行了。

 

猜你喜欢

转载自blog.csdn.net/Oceanside_yh/article/details/82877691