黑马程序员:hibernate测试异常的解决:Hibernate Validator bean-validator-3.0-JBoss-4.0.2...

本文讨论了在使用Hibernate进行数据库操作时遇到的配置文件异常问题,并提供了通过在配置文件中添加特定属性来解决这些问题的方法。文章还强调了在开发过程中确保正确配置Hibernate以避免常见错误的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[align=center]------- [url=http://edu.youkuaiyun.com/heima]android培训 [/url]、[url=http://edu.youkuaiyun.com/heima]java培训[/url]、期待与您交流!------- [/align]

hibernate.cfg.xml配置文件如下:

<hibernate-configuration>

<session-factory>

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 数据库连接 -->
<property name="connection.url">jdbc:mysql://localhost:3306/db_database14</property>
<!-- 数据库连接用户名 -->
<property name="connection.username">root</property>
<!-- 数据库连接密码 -->
<property name="connection.password">root</property>
<!-- 数据库驱动 -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 打印SQL语句 -->
<property name="show_sql">true</property>
<!-- 自动建表 -->

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

<mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>


测试的时候包以下异常:
[quote]2012-5-23 23:01:53 org.hibernate.annotations.common.Version <clinit>
信息: Hibernate Commons Annotations 3.2.0.Final
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: Hibernate 3.6.10.Final
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: hibernate.properties not found
2012-5-23 23:01:53 org.hibernate.cfg.Environment buildBytecodeProvider
信息: Bytecode provider name : javassist
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2012-5-23 23:01:53 org.hibernate.cfg.Configuration configure
信息: configuring from resource: /hibernate.cfg.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration getConfigurationInputStream
信息: Configuration resource: /hibernate.cfg.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration addResource
信息: Reading mappings from resource : org/hibernate/tutorial/hbm/Event.hbm.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration doConfigure
信息: Configured SessionFactory: null
2012-5-23 23:01:53 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: org.hibernate.tutorial.hbm.Event -> EVENTS
2012-5-23 23:01:53 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL
信息: Hibernate Validator not found: ignoring
2012-5-23 23:01:53 org.hibernate.validator.util.Version <clinit>
信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2[/quote]

解决方案,在配置文件中加上下面一句既可:
<property name="javax.persistence.validation.mode">none</property>  


[align=center]------- [url=http://edu.youkuaiyun.com/heima]android培训 [/url]、[url=http://edu.youkuaiyun.com/heima]java培训[/url]、期待与您交流!------- [/align]

[align=center]详细请查看:[url=http://edu.youkuaiyun.com/heima]http://edu.youkuaiyun.com/heima [/url]------- [/align]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值