Unable to get the default Bean Validation
来源:互联网 发布:网络电视老是卡怎么办 编辑:程序博客网 时间:2024/05/21 02:34
按照马士兵的ssh整合视频开始配置ssh架构,但是由于版本不相近遇到了两个问题,特此记录下:
1.java.lang.NoSuchFieldError: INSTANCEat org.hibernate.type.BasicTypeRegistry.(BasicTypeRegistry.java:94)at org.hibernate.type.TypeResolver.(TypeResolver.java:59)at org.hibernate.cfg.Configuration.(Configuration.java:249)at org.hibernate.cfg.Configuration.(Configuration.java:300)
经过查找发现是hibernate-annotations.jar和hibernate-commons-annotations.jar的问题,hibernate.jar已经将其整合
2.去掉两个包之后出现
Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bolo.examples.dao.base.UserDao com.bolo.examples.service.base.UserManager.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [E:\MyEclipse9.0\workspace\ssh2\WebRoot\WEB-INF\classes\com\bolo\examples\dao\base\UserDao.class]: Initialization of bean failed; nested exception is 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
也是一番查找之后发现在
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory
加入红色部分就没有问题了
真是不同的版本差异比较大啊
其实这个问题是我们自己造成的!为什么这么说?因为我们在配置Spring和Hibernate进行结合的时候版本出现了问题。
<persistence ...>
</persistence>
这是hibernate官方文档的一段话!
意思就是在hibernate.cfg.xml或者是
persistence.xml文件下面需要配置
javax.persistence.validation.mode属性!
特别的!在Hibernate中默认的
<prop key="javax.persistence.validation.mode">none</prop>
是auto而不是none!
------------------------------------------------------------------------------------------------------------------------------------------
javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包,但是找不到,所以beanvalitionFactory错误。
由于javax.persistence.validation.mode的属性值默认是auto,所以会出错。
在hibernate.cfg.xml里将javax.persistence.validation.mode设置为none,就可以避免出错了。
------------------------------------------------------------------------------------------------------------------------------------------
所以,Hibernate 3.6以上版本在用junit测试时会提示错误:
Unable to get the default Bean Validation factory
在hibernate.cfg.xml里增加一属性解决:
源自:http://blog.sina.com.cn/s/blog_6ac4c6cb01018rl2.html
- Unable to get the default Bean Validation
- Unable to get the default Bean Validation
- Unable to get the default Bean Validation
- Unable to get the default Bean Validation factory
- HibernateException:Unable to get the default Bean Validation factory
- hibernate3.6:Unable to get the default Bean Validation factory
- Unable to get the default Bean Validation factory异常处理
- Unable to get the default Bean Validation factory
- Unable to get the default Bean Validation factory
- hibernat异常:Unable to get the default Bean Validation factory
- hibernat异常:Unable to get the default Bean Validation factory
- hibernat异常:Unable to get the default Bean Validation factory
- Unable to get the default Bean Validation factory
- hibernat异常:Unable to get the default Bean Validation factory
- Hibernate异常: Unable to get the default Bean Validation factory
- Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- vm使用技巧(未完)
- 佛挡杀佛第三方的身份
- 求一个序列的子序列个数(序列元素是一个字符)
- Qt下使用GDB远程调试ARM板
- Windows 7-64位上编译webkit源码纪实
- Unable to get the default Bean Validation
- 论文发表的建议
- UVa 10038 / POJ 2575 / ZOJ 1879 Jolly Jumpers (water ver.)
- POJ 2606 / URAL 1502 Rabbit hunt (计算几何)
- 20130921
- UVa 10082 WERTYU (water ver.)
- 18 - generate parentheses
- UVa 10370 Above Average (water ver.)
- 安装mono for android 4.2.5后出现启动vs报错 的解决方式