Search code examples
javahibernatemavenbatch-filemaven-assembly-plugin

Externalize hibernate.cfg.xml from war maven


I'am packing my java web application to a zip file containing all dependencies and other things .. using maven assembly plugin, and i wrote a batch script so as to deploy the war and run it without openning eclipse ...

the problem here is that i want to run this batch file for others Databases in other computers, here i need your help to tell me if there is a way to externalize the hibernate.cfg.xml to directly configure the databases to whom my application will be linked to.

Thanks in advance


Solution

  • I Have found that I must specify the connection properties (Username, password, connection.url, dialect ...) in the hibernate.properties. And the class mapping must remain in the hibernate.cfg.xml file. And by placing them both at the resources, Hibernate will locate them both and extract what he needs :D