zoukankan      html  css  js  c++  java
  • 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

    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>

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

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

  • 相关阅读:
    二叉树——数组的异或和
    二叉树——最长子数组累加和
    二叉树——平衡二叉搜索树 TreeSet, TreeMap
    二叉树——大楼的轮廓线
    数据结构--Morris遍历--二叉树的遍历
    数据结构--单调栈--烽火台
    数据结构--单调栈--求最大子矩阵的大小
    数据结构--单调栈--构造数组的MaxTree
    数据结构--单调栈结构
    字符串的压缩和解压缩
  • 原文地址:https://www.cnblogs.com/liuyangfirst/p/6094668.html
Copyright © 2011-2022 走看看