读书人

struts Hibernate模式出的

发布时间: 2012-01-28 22:06:14 作者: rapoo

struts Hibernate模式出的
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at example.test.TestHibernate.main(TestHibernate.java:21)

hibernate.cfg.xml已配置好了代如下:

<?xml version= "1.0 " encoding= "utf-8 "?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN "
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd ">

<hibernate-configuration>
<session-factory>

<!-- local connection properties -->
<property name= "hibernate.connection.url ">
jdbc:microsoft:sqlserver://localhost:1433;databasename=WebOrder
</property>
<property name= "hibernate.connection.driver_class ">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<property name= "hibernate.connection.username "> sa </property>
<property name= "hibernate.connection.password "> sa </property>
<!-- property name= "hibernate.connection.pool_size "> </property -->

<!-- dialect for Microsoft SQL Server -->
<property name= "dialect "> org.hibernate.dialect.SQLServerDialect </property>

<property name= "hibernate.show_sql "> false </property>
<property name= "hibernate.transaction.factory_class ">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name= "myeclipse.connection.profile "> 22 </property>
<property name= "connection.url "> jdbc:microsoft:sqlserver://localhost:<1433>databasename=WebOrder </property>
<property name= "connection.username "> sa </property>
<property name= "connection.password "> sa </property>
<property name= "connection.driver_class "> com.microsoft.jdbc.sqlserver.SQLServerDriver </property>
</session-factory>
</hibernate-configuration>

什么提示找不到配置文件的信息?能指一下迷津


[解决办法]
应该是你项目启动的问题~
启动的时候没找到hibernate.cfg.xml~

检查一下你的hibernate.cfg.xml存放路径,路径设置等~
[解决办法]
到hibernateSessionFactory里面看看你的hibernate.cfg.xml路径设置是否和你的真实路径一样!
[解决办法]
常见问题,sessionfactory里的confige(Sring)有参数,是xml文件的路径

读书人网 >Eclipse开发

热点推荐