spring与hibernate整合然后出现如下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
Caused by: java.lang.NullPointerException

分析错误原因就是编译器无法识别和找到bean的validate包,但是,这个包确实存在的,然后根据查询发现hibernate有一个属性javax.persistence.validation.mode,这个属性默认是auto的,但是这样的话,编译器就无法识别了,所以需要我们手动设置一下,所以找到你的hibernate.cfg.xml文件,将这个属性加入进去。

<property name="javax.persistence.validation.mode">none</property>

加入后上述问题全部没有了,写的测试类,就好使了。

希望犯愁的小伙伴可以解决这个问题,多谢您的支持,没事请点赞!!!

Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable t的更多相关文章

  1. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

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

  2. 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' ...

  3. MyBatis笔记----报错:Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/ij34/mybatis/applicationContext.xml]: Invocation of init method failed; nested exception is org.sp

    四月 05, 2017 4:51:02 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...

  4. 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 ...

  5. Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cannot resolve reference to bean 'factory' while setting bean property 'sqlSessionFactory'; nested excep

    Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cann ...

  6. 报错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 ...

  7. 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 ...

  8. 使用SpringMVC报错 Error creating bean with name 'conversionService' defined in class path resource [springmvc.xml]

    使用SpringMVC报错 Error creating bean with name 'conversionService' defined in class path resource [spri ...

  9. 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 ...

随机推荐

  1. UI5-文档-4.16-Dialogs and Fragments

    在这一步中,我们将进一步研究另一个可以用来组装视图的元素:the fragment. 片段是轻量级UI部件(UI子树),可以重用,但是没有任何控制器.这意味着,每当你想定义一个特定UI的一部分是跨多个 ...

  2. 压缩文件tar.gz和zip之间的区别

    我们在开发的时候通常要先下载相关的软件或者是源码,或者是jar包.在下载东西的时候总是碰见后缀是.tar.gz和.zip的问题,搞不清楚是怎么回事,不晓得下载哪个文件才是对自己有用的.现在我知道了,其 ...

  3. MPP、SMP、NUMA概念介绍

    一.MPP,SMP,NUMA概念介绍 1.1.       MPP架构介绍 MPP (Massively Parallel Processing),大规模并行处理系统,这样的系统是由许多松耦合的处理单 ...

  4. C++连接Oracle之OCCI(windows)

    上一节我们讲过了ADO连接Oracle,这一节我们尝试通过OCCI的方式,来在windows平台下连接Oracle数据库,下一节讨论在Linux环境下通过OCCI的方式连接远程的Oracle数据库. ...

  5. (4)shiro多个realm

    shiro支持多个realm,当设置多个realm的时候,shiro的认证和授权的步骤是怎样的呢. 多个realm认证原理: 发现需要在执行认证的时候,需要策略来处理多个realm存在的情况.默认实现 ...

  6. scala--函数式对象

    函数式对象 这次写点关于函数式对象的吧 class Rational(n:Int, d:Int) { // n,d 为类参数,scala会创造出同样带有这两个参数的主构造器.如果这个类没有主体,可以不 ...

  7. SVM总结(转)

    支持向量机 看了JULY君的博客和文档后,个人对SVM的理解和总结,欢迎交流和指正.其理论部分可以查看下面文档链接,通俗易懂. 支持向量机通俗导论(理解SVM的三层境界)     第一篇:从四个关键词 ...

  8. java 解析命令行参数

    下载地址: https://jcenter.bintray.com/org/apache/commons/com.springsource.org.apache.commons.cli/1.2.0/ ...

  9. Hibernate分页查询的两个方法

    Hibernate中HQL查询语句有一个分页查询, session.setMaxResult(参数)和session.setFirstResult(参数) 如果只设置session.setMaxRes ...

  10. Maven项目的拆分与聚合

    ---------------------siwuxie095                                     Maven 项目的拆分与聚合         1.对已有的 Ma ...