我正进入(状态
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">
在春季使用import-导入休眠文件
<import resource="hibernate.cfg.xml"/>
Jar存在于Maven依赖项中,但仍无法加载DTD
您无需hibernate.cfg.xml
在Spring应用程序上下文中导入。
因此,与其具有:
<import resource="hibernate.cfg.xml"/>
您需要确保hibermate.cfg.xml位于jars中的某个位置。
如果您使用的是Maven,则将其放在以下路径中:
${project.home}/src/main/resources/hibernate.cfg.xml
这样,hibernate.cfg.xml
文件将在构建期间包含在模块jar中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句