Unable to get the default Bean Validation factory

来源:互联网 发布:java安装方法 编辑:程序博客网 时间:2024/06/03 19:24

在使用Spring和Hibernate进行结合的时候出现了这个问题!

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

在配置文件中添加这个!

 <property name="hibernateProperties">
   <props>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="javax.persistence.validation.mode">none</prop> 
   </props>
  </property>

其实这个问题是我们自己造成的!为什么这么说?因为我们在配置Spring和Hibernate进行结合的时候版本出现了问题。
<persistence ...>  
  <persistence-unit ...>  
    ...  
    <properties>  
      <property name="javax.persistence.validation.mode"  
                value="callback, ddl"/>  
    </properties>  
  </persistence-unit>  
</persistence>  
这是hibernate官方文档的一段话!

意思就是在hibernate.cfg.xml或者是
persistence.xml文件下面需要配置
javax.persistence.validation.mode属性!

特别的!在Hibernate中默认的 <prop key="javax.persistence.validation.mode">none</prop>
是auto而不是none!


原创粉丝点击