【发布时间】:2014-12-05 11:35:44
【问题描述】:
我来了
Caused by:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to import bean definitions from relative
location [hibernate.cfg.xml] Offending resource: ServletContext
resource [/WEB-INF/applicationContext.xml]; nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from ServletContext resource
[/WEB-INF/hibernate.cfg.xml]; nested exception is
java.io.FileNotFoundException: class path resource
[org/hibernate/hibernate-configuration-3.0.dtd] cannot be opened
because it does not exist
这是我正在使用的依赖项
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
hibernate.cfg.xml -
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration SYSTEM
"classpath://org/hibernate/hibernate-configuration-3.0.dtd">
在spring中使用import导入hibernate文件-
<import resource="hibernate.cfg.xml"/>
Jar 存在于 maven 依赖项中,但仍无法加载 DTD
【问题讨论】:
-
为什么不直接删除 DOCTYPE?它是否定义实体?
-
只想提到XML Catalogs 作为外部DTD 的替代品。 -
"classpath:///org..."或单个/? -
你试过
<!DOCTYPE hibernate-configuration SYSTEM "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">吗?这也适用于离线。
标签: java xml spring hibernate configuration