Hibernate异常: Unable to get the default Bean Validation factory

项目原本是部署在Tomcat下没有问题的,改为TongWeb6.1就报如下错误(截取部分),而且TongWeb6.0也是没有问题的。

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:1677)
    at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1627)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1418)
    at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1348)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods
    (AbstractAutowireCapableBeanFactory.java:1514)
(AbstractAutowireCapableBeanFactory.java:1452)

解决方法是在hibernate.cfg.xml配置文件中 或许名称不一定叫这个 但是在配置sessionFactory的bean节点下

加上如下属性:

<prop key="javax.persistence.validation.mode">none</prop>

上下文:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="oracledataSource"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                <prop key="hibernate.show_sql">true</prop> 
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="javax.persistence.validation.mode">none</prop>
            </props>
        </property>     
</bean>

作者:itmyhome

©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页