Hibernate配置问题:“严重: problem parsing configuration/hibernate.cfg.xml”

leafxx leafxx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我按照书上所说配置hibernate
以下是我的文件目录:
HibernateSample -- /org /hibernate/ sample ;存放源文件

/classes /org /hibernate /sample ;存放class文件和.hbm.xml

-------------------------------------------------------------------------------
------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-2.0.
dtd">
<hibernate-configuration>
<!—- SessionFactory 配置 -->
<session-factory>
<!—- 数据库URL -->
<property name="hibernate.connection.url">
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
</property>
<!—- 数据库JDBC驱动 -->
<property name="hibernate.connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<!—- 数据库用户名 -->
<property name="hibernate.connection.username">
sa
</property>
<!—- 数据库用户密码 -->
<property name="hibernate.connection.password">
lefx8233
</property>
<!--dialect ,每个数据库都有其对应的Dialet以匹配其平台特性 -->
<property name="dialect">
net.sf.hibernate.dialect.SQLServerDialect
</property>
<!—- 是否将运行期生成的SQL输出到日志以供调试 -->
<property name="hibernate.show_sql">
True
</property>
<!—- 是否使用数据库外连接 -->
<property name="hibernate.use_outer_join">
True
</property>
<!—- 事务管理类型,这里我们使用JDBC Transaction -->
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>

<!—映射文件配置,注意配置文件名必须包含其相对于根的全路径 -->
<mapping resource="org.hibernate.sample.Store.hbm.xml"/>
</session-factory>
</hibernate-configuration>

------------------------------------------------------------------------------------

所有所需要的jar包都已经引入

但是在eclipse下运行时报错,百思不得其解

2005-4-14 11:01:23 net.sf.hibernate.cfg.Environment <clinit>
信息: Hibernate 2.1.8
2005-4-14 11:01:23 net.sf.hibernate.cfg.Environment <clinit>
信息: hibernate.properties not found
2005-4-14 11:01:23 net.sf.hibernate.cfg.Environment <clinit>
信息: using CGLIB reflection optimizer
2005-4-14 11:01:23 net.sf.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2005-4-14 11:01:23 net.sf.hibernate.cfg.Configuration configure
信息: configuring from resource: /hibernate.cfg.xml
2005-4-14 11:01:23 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
信息: Configuration resource: /hibernate.cfg.xml
2005-4-14 11:01:25 net.sf.hibernate.cfg.Configuration doConfigure
严重: problem parsing configuration/hibernate.cfg.xml
org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:358)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:967)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at org.hibernate.sample.Hibernate.main(Hibernate.java:32)
Nested exception:
java.net.UnknownHostException: hibernate.sourceforge.net
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:967)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at org.hibernate.sample.Hibernate.main(Hibernate.java:32)
net.sf.hibernate.HibernateException: problem parsing configuration/hibernate.cfg.xml
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:972)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at org.hibernate.sample.Hibernate.main(Hibernate.java:32)
Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:358)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:967)
... 3 more
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.sample.Hibernate.main(Hibernate.java:41)
...全文

相关推荐

腾讯云服务器CentOS7系统上安装JDK+Tomcat+MySQL

本人在Linux系统和服务器架设上是初学者,本文如有错误或不妥之处,请指出,谢谢. 安装前先检查一下有没有安装好了的JDK,Tomcat,MySQL,不过一般都没有. 1.安装JDK 1.1 下载jdk,可以到官网查看不同版本的下载地址 wget --no-check-certificate --no-cookies --header "Cookie: oraclelicens

星_尘

centos7搭建hadoop

前言 hadoop是其他大数据框架的基础运行环境,尤其是hdfs,是其他大数据框架的基础存储载体,因此学习和掌握hadoop对学习大数据很有必要 haddop常用的3种运行模式包括: 本地模式 ,单机运行,只是用来演示一下官方案例。生产环境不用 伪分布式模式,也是单机运行,但具备Hadoop集群所有功能,一台服务器模拟一个分布式的环境 完全分布式模式:多台服务器组成分布式环境。生产环境使用 本篇将基于centos7系统,在腾讯云环境快速搭建一个单节点的haddop运行环境 前置准备 一台配置好网络连接

小码农叔叔

腾讯云 Centos7.4 部署Java Web项目并通过域名访问

    周末这两天在家部署Java项目,因为是第一次在Linux系统上操作,所以都是一边看别人的资料一边敲代码!效率很慢,走了很多弯路,遇到很多困扰,,但好在最后达到了自己的预期!这中间的过程对我来说是宝贵的,有可能后来的人也会遇到,所以简单整理了一下!一、部署环境    参考 :腾讯云 Centos7.0 配置JAVA运行环境 (jdk8+tomcat7+mysql)    注意 :    to...

Jorn_Lee

利用腾讯云服务器Centos7+Tomcat搭建个人网站

之前看腾讯云服务器学生打折,就买了一个,花了较长的时间等待域名备案,最近有些时间便琢磨着搭建一个个人网站,弄个博客,之后毕设也是web系统可以放上去,还是美滋滋,再次记录一下,大体只是为了自己记忆,如有幸被人路过看到,仅供参考。 首先是申请云服务器和备案,个人使用的是腾讯云,无他,那段时间(2017年11月的样子)这个是大厂里最便宜的(对在校生有优惠)。申请流程在官网一步到位,就是备案耗了很久,

乐真

政府科技管理者如何提升区域科技成果转化成功率?.docx

政府科技管理者如何提升区域科技成果转化成功率?

BIZKEEN
评论 5
收藏 已收藏
分享
返回顶部
leafxx
Java EE 67,535 成员 225,843 内容