hibernate和spring整合:Unable to get the default Bean Validation factory

在使用Spring和Hibernate進行結合的時候出現了這個問題!java

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

在hibernate配置文件中添加這個!.net

 <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>hibernate

<!-- 關閉bean validate驗證 -->
    <prop key="javax.persistence.validation.mode">none</prop> 
   </props>
  </property>orm

xml

<!-- 關閉bean validate驗證 -->
<property name="javax.persistence.validation.mode">none</property> blog

其實這個問題是咱們本身形成的!爲何這麼說?由於javaee6有bean-validator.jar這個包,用javae5就沒事了,咱們也可把這個包刪除了文檔


<persistence ...>   
  <persistence-unit ...>  
    ...  
    <properties>  
      <property name="javax.persistence.validation.mode"  
                value="callback, ddl"/>  
    </properties>  
  </persistence-unit>  
</persistence>  
這是hibernate官方文檔的一段話!it

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

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

 

愚見!有不一樣的想法的請留言!謝謝 ———————————————— 版權聲明:本文爲CSDN博主「q1054261752」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。 原文連接:https://blog.csdn.net/q1054261752/article/details/52564213

相關文章
相關標籤/搜索