Hibernate does not find Hibernate.cfg.xml

Asked

Viewed 119 times

0

. When indicating the configuration file to Hibernate, I tried the wrong relative path before ". cgf) (.. /.. /main/Resources/Hibernate.cgf.xml). But now corrected, the absolute and Hibernate path does not update, keep looking as if I had passed the wrong relative path...

See below for the configuration class where I indicate . cfg and the error below:

inserir a descrição da imagem aqui

  • 1

    Hibernate. cgf .xml?

  • I typed wrong. .cfg.xml

  • I didn’t type wrong. It’s written like this in the Hibernate error message, look.

  • Are you sure the message is not simply showing the name typed by you?

  • This may be what I typed before, but I fixed, saved, closed and opened the Eclipse, and continues to accuse that typing wrong anthers. Look what I typed in the code above.

  • Got it. Strange that the wrong name persists in the error message.

  • I even restarted the computer and it didn’t help. There is no other place where I pass.cfg ...

  • 1

    Have you ever just tried configuration.configure()? Hibernate will find the cfg of your application. If you need to inform an absolute path file, the answer is in that other post

  • I tried now, nothing changes.

Show 4 more comments

1 answer

1


The structure of your Eclipse project is a little strange. Whereas it is a Java project with Maven and it was imported as Maven project, it should be like this its tree:

inserir a descrição da imagem aqui

Since it is not in this structure, the Maven plugin is not putting the content of src/main/resources in the classpath.

To fix the structure, right-click on your project and run "Maven/Update Project". Once this is fixed, use only configuration.configure() and Hibernate will find your cfg file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.