How can I configure IntelliJ to include Hibernate config in target folder?

I'm starting to work with Hibernate a little and seem to have an issue with the Hibernate config not being included when I build and run the app. I'm having to copy the config over to the ./target/classes/ directory manually to get it to run.

The project was created using a maven-archetype-quickstart Maven archetype. My Hibernate config was named hibernate.cfg.xml and placed under the Java directory, which was marked as the sources root.

Should this file be included in the build? Is there a setting that I need to configure to get IntelliJ to copy this file over correctly?

2 comments
Comment actions Permalink

Hello.

If the project is based on Maven then IDEA tries to follow Maven behavior as possible. With specified project configuration command line Maven also does not copy the file, so it's not an IDEA-specific problem.

I've found a Maven + Hibernate example on the web:
http://www.mastertheboss.com/jboss-frameworks/hibernate-jpa/maven-hibernate-jpa/maven-and-hibernate-4-tutorial
They say the hibernate config should be in resources/META-INF. For me, with this configuration both IDEA and standalone Maven copy the file.

Regards,
Alexander.

0
Comment actions Permalink

Thanks! I didn't realize I needed to keep a resources folder, though I had a hunch it was a maven-related project-config problem.

0

Please sign in to leave a comment.