解决方法
在hibernate.cfg.xml配置文件中加入以下配置:
<property name="javax.persistence.validation.mode">none</property>
产生原因
配置Spring和Hibernate进行结合的时候版本出现了问题
javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包,但是找不到,所以beanvalitionFactory错误。
由于javax.persistence.validation.mode的属性值默认是auto,所以会出错。
在hibernate.cfg.xml里将javax.persistence.validation.mode设置为none,就可以避免出错了。
<!-- Disable the BeanValidation -->
<property name="javax.persistence.validation.mode">none</property>
总结:
Hibernate 3.6以上版本在用junit测试时会提示错误:
Unable to get the default Bean Validation factory
在hibernate.cfg.xml里增加一属性解决:
<property name="javax.persistence.validation.mode">none</property>