hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory(示例代
Posted haha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory(示例代相关的知识,希望对你有一定的参考价值。
最近在自学Hibernate与Struts2进行集成时,出现了一个错误,错误截图如下:
错误代码如下:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.ExceptionInInitializerError at com.itheima.utils.Test.main(Test.java:5) Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127) at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1704) at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1654) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856) at com.itheima.utils.HibernateUtils.<clinit>(HibernateUtils.java:19) ... 1 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118) ... 6 more Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383) at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109) ... 11 more Caused by: javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath. at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271) at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110) at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380) ... 12 more
我们先看下hibernate的帮助文档,该文档所在位置:\\hibernate-distribution-3.6.10.Final\\documentation\\manual\\zh-CN\\html ,可以看中文版本的,有如下描述,截图如下:
这里大意就是在 hibernate.cfg.xml 或者是 persistence.xml 文件下面需要配置
javax.persistence.validation.mode 属性,
于是我们在 hibernate.cfg.xml 文件里添加属性,如下截图所示:
<property name="javax.persistence.validation.mode">none</property>
以上是关于hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory(示例代的主要内容,如果未能解决你的问题,请参考以下文章
Hibernate卡住,然后报错java.sql.SQLException: Unknown system variable 'language'异常
如果 mysql 不存在 Hibernate 4 和 spring 4,则不会自动创建模式
当没有 Internet 连接时,Hibernate 给出错误错误,因为“当 'hibernate.dialect' 未设置时,访问 DialectResolutionInfo 不能为空”