struts Hibernate模式開發出現的問題解决方案

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:&lt;1433&gt;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文件的路径