今天复习一下Spring和Hibernate的整合,遇到了一个问题,报错信息如下:

  org.springframework.beans.factory.xml。XmlBeanDefinitionStoreException:来自类路径资源的XML文档中的第1行是无效的;嵌套异常                     

  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [] is invalid; nested exception is     org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。

  根据其意思是XML的文件出现了问题,网上说的问题是 更改xml文件的编码、xml文件第一行有空格 等,折腾了几次,最后发现是没有指定解析哪个xml文件。(如图)

  1. 错误:未指定xml文件路径

  

  2. 正确

  

  总结:这个问题折腾了不少时间,算是为自己的马虎大意付出了代价。

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException 前言中不允许有内容 来自类路径资源的XML文档中的第1行是无效的的更多相关文章

  1. 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]

    报这种错的原因基本上是applicationContext.xml文件中bean配置错误,错误如下: org.springframework.beans.factory.BeanCreationExc ...

  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined ...

  3. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

  4. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is

    在复制xml文件进行修改的时候,我经常将不小心对原文件进行修改,而导致创建bean出错.报错如下所示: Exception sending context initialized event to l ...

  5. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [app2.xml]: Instantiation of bean failed; nested exception is org.spr

    在学习spring整合hubernate时遇到的问题.c3p0遇到了一个问题,老连不上,显示java.lang.NoClassDefFoundError:com.mchange.v2.ser.Indi ...

  6. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deptDao_a' defined in class path resource [beansAndHibernate.xml]: Cannot resolve reference to bean 'sessionFact

    Error creating bean with name 'deptDao_a' defined in class path 因为更改了类的名字,所以其setter方法没有更改,需要 private ...

  7. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Initialization of bean failed

  8. 开发Spring过程中几个常见异常(二):Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'a' define

    本异常是小编在运行自己另外一篇博文中的例子时遇到的.(附博文:http://www.cnblogs.com/dudududu/p/8482487.html) 完整异常信息: 警告: Exception ...

  9. java项目报错: org.springframework.beans.factory.BeanCreationException找不到mapper.xml文件

    错误代码 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSer ...

随机推荐

  1. 06_传智播客iOS视频教程_源文件后缀名和main函数

    OC与C语言的不同. 把OC程序运行起来,CPU只会找main函数.并且只会执行main函数当中的代码.当main函数的代码执行完毕之后这个程序就自动结束掉了. main函数的参数是可以让我们在运行程 ...

  2. package-lock.json到底是干嘛的?(转载)

    package-lock.json到底是干嘛的? https://mp.weixin.qq.com/s/NaVVljKrQAFmHMdbkaYmPg## nvm-windows https://git ...

  3. PCB CAM自动化后台配置说明

    CAM自动化项目经历9个月时间里,在我们IT团队与工程部深入合作下,依据PCB各种场景定制特定功能,且这几个月里在不断的改进与迭代脚本功能,在此期间攻破了一个又一个难题,最终项目第一阶段已顺立上线运行 ...

  4. Linux 常用命令七 grep

    一.grep命令 grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜 ...

  5. python 37条编程技巧-汇总(转载+整理)

    1.原地交换两个数字 x, y =10, 20 print x, y y, x = x, y print x, y 10 20 20 10 2.链状比较操作符 n = 10 print 1 < ...

  6. 安装 Spring 框架库

    下载地址:http://repo.spring.io/release/org/springframework/spring

  7. [Usaco2012 Nov]Concurrently Balanced Strings

    Description [Brian Dean, 2012] Farmer John's cows are all of a very peculiar breed known for its dis ...

  8. SIFT特征点检测与匹配

    SIFT的步骤如下: (1) 尺度空间极值检测(Scale-space Extrema Detection) 也就是在多尺度高斯差分(Difference of Gauss)空间中检测极值点(3x3x ...

  9. ASP.NET CORE 使用 EF CORE访问数据库

    asp.net core通过ef core来访问数据库,这里用的是代码优先,通过迁移来同步数据库与模型. 环境:vs2017,win10,asp.net core 2.1 一.从建立asp.net c ...

  10. 自动判断手机版和pc版

    <html><head><title>欢迎来到手机版</title><script>var ua = navigator.userAgent ...