请问各位:
我在使用junit进行单元测试的时候,到实例化SessionFactory的时候不成功,控制台打印的信息如下:
2013-8-14 15:36:45 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-8-14 15:36:45 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.9.Final}
2013-8-14 15:36:45 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
2013-8-14 15:36:45 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-8-14 15:36:45 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/TempPrice.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/Product.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/CurrentPrice.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupCode.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupType.hbm.xml
2013-8-14 15:36:45 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: [color=red]Configured SessionFactory: null[/color]
我检查过我的hibernate.cfg.xml文件和未发现错误。如下:
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="connection.username">POSMAN</property>
<property name="connection.password">POSMAN</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="com/hanqi/po/TempPrice.hbm.xml"/>
<mapping resource="com/hanqi/po/Product.hbm.xml"/>
<mapping resource="com/hanqi/po/CurrentPrice.hbm.xml"/>
<mapping resource="com/hanqi/po/LookupCode.hbm.xml"/>
<mapping resource="com/hanqi/po/LookupType.hbm.xml"/>
</session-factory>
xxx.hbm.xml文件我也检查过未发现问题,请问会是在哪个地方出的错。
感谢!
1 代码没问题的话,请把所有的映射文件删除,看下是什么效果
2 把配置属性修改成
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:orcl
POSMAN
POSMAN
官方文档时这种写法
http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/session-configuration.html
只有这些报错信息吗?
你的错误信息:INFO: HHH000206: hibernate.properties not found
需要的属性文件没找到,那么很可能你的jar包没放对位置
也可能hibernate.cfg.xml 路径问题吧!仔细检查!