把你的在web.xml文件贴出来看看。
解决方案 »
- 急-->Hibernate3 返回查询结果为Map时 ,字段值被截断,在线等
- 写ssh的时候有了一个删除实体的疑惑
- jms 队列问题 环境,myeclipse9.0+jboss6
- 请问大虾,struts2中标签<s:if>怎么对比String?
- 十万火急二,请各位仁兄帮忙看看,接上!
- 如何发现非法的代理服务器
- 简单问题,struts中获取值问题,100分求解
- 各位,救救我吧,实在受不了了.
- 帮助意思翻译!!!!
- 程序员妹子遇难题,欧巴在哪里!?
- java axis客户端,怎样调用.net WCF 服务? 中间有用户验证
- <BEA-101083> <Connection failure. java.net.SocketException: 管道断开 (errno:32)
hibernate.cfg.xml文档如下:
<?xml version="1.0" endcoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>
<session-factory>
<property name="show_sql">
true
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost/YF
</property>
<property name="connection.user">
root
</property>
<property name="connection.password">
yaofang
</property>
<!-- 以下设置对象与数据库表格映射文件 -->
<mapping resource="User.hbm.xml"/>
</session-factory></hibernate-configuration>
Configuration config = new Configuration().configure("/hibernate.cfg.xml");我得hibernate.cfg.xml文件就是放在工程的目录下的 再 Eclipse中和src目录是一个级别. 再麻烦看看,谢谢!
或者你试试指定文件的位置,比如放在是src/resource下面,调用new Congiuration().configure("resource/hibernate.cfg.xml");
我给大家加分. 谢谢了!
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: resource/hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1354)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
at caterpillar.hibernate.HibernateDemo.main(HibernateDemo.java:9)
Caused by: org.dom4j.DocumentException: Error on line 1 of document : The encoding declaration is required in the text declaration. Nested exception: The encoding declaration is required in the text declaration.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1344)
... 2 more
不过可以先建立一个 hibernate.xml文档 里面写好了后,在把hibernate.xml 的内容粘贴到hibernate.cfg.xml里么面就可以了.
不过建立hibernate.cfg.xml文档时 只能 以新建 File的形式 建立文件
Configuration config = new Configuration().configure("hibernate/cfg/hibernate.cfg.xml");
这里面写上你的配置文件路径,就能找到