Hibernate.cfg.xml not exported to executable jar

When I try to export the project to an executable .jar file then the config files like hibernate.cfg.xml or log4j-properties are not exported to the jar. I have to add them manually to the archive. The files are located in the / target / folder in the root folder of the project.

How do I get Eclipse to export config files too?

+1


source to share


2 answers


Just create a resource folder parallel to your source / src folder and save your config files there.



+2


source


If you are using Eclipse approach:

Project >> Export >> Java >> 
Runnable JAR File >> Package required libraries into generated JAR

      



Only class files are exported to the jar and - if selected - linked libraries.

However, you can create an additional source folder (name resources

or config

whatever suits your case) and copy the files to that file. This directory will also be part of your generated jar file.

+1


source







All Articles