/ / hibernacja DTD nie ładuje się za pomocą ścieżki klas, słoik tam jest, wciąż pobiera filenotfound - java, xml, wiosna, hibernacja, konfiguracja

hibernacja DTD nie ładuje się za pomocą ścieżki klasy, słoik tam jest, wciąż pobiera filenotfound - java, xml, wiosna, hibernacja, konfiguracja

staje się

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

jest to zależność, której używam

        <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">

importowanie pliku hibernacji na wiosnę za pomocą importu

<import resource="hibernate.cfg.xml"/>

Jar jest w zależnościach, ale nadal nie może załadować DTD

Odpowiedzi:

1 dla odpowiedzi № 1

Nie importujesz hibernate.cfg.xml jako kontekstu aplikacji Spring, więc zamiast:

<import resource="hibernate.cfg.xml"/>

Musisz upewnić się, że plik hibermate.cfg.xml znajduje się gdzieś w twoich słoikach.

Jeśli używasz Mavena, po prostu umieść go w następującej ścieżce:

${project.home}/src/main/resources/hibernate.cfg.xml

W ten sposób plik hibernate.cfg.xml zostanie dołączony do modułu modułu podczas budowania.