您的位置:首页 > 编程语言 > Java开发

继续Java,整合Spring Hiberate

2014-08-28 03:33 239 查看
我直接把配置文件copy过来的,遇到了2个问题,

1,打开Hibernate.cfg.xml 时,弹出窗口:"this project is not a myeclipse hibernate project . assuming hibernate 3 ...",百度后得到更正的方法:

使用版本控制的时候,工程根目录下的: .project 和 .myhibernatedata 文件不在版本控制范围内,因此组内成员更新source后,缺少.project 内的ature>com.genuitec.eclipse.hibernate.hibernatenature</nature> 和.myhibernatedata 文件。

解决:项目名上右键--〉myeclipse-->add hibernate capabilites -->next-->hibernate config file --> existing -->选择现有工程存在的hibernate配置文件--> next --> 不生成factory class --> end

摘自:/article/1794697.html

2. 测试spring和Hibernate的整合,报错:

“Unable to get the default Bean Validation”

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>

第二个错几乎用了2个小时。哎,不熟悉呀。不过还是解决了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐