I'm very new to maven and running into some mandatory beginners problem. What I want is to maven along with hibernate. I have read and googled a lot concerning this problem of mine, however, I don't find a solution.
Here's my source dir structure:
compilation is no issue, but when I try and run the class by java -cp .... I get the error:
Obviously, the hibernate.cfg.xml was not copied into the jar. Adding it manually resolves this problem, however, after fixing this issue, the code complains about missing the mapper com.sas.bo.CW.hbm.xml. Hence, Maves does not copy any of the xml files, even though at leas one is in the appropiate resource path.
How can I make Maven include these .xmls when packaging the jar? Any advice is most welcome.
I think your POM may be more complicated that it needs to be, since there are a lot of defaults available, and I'm not even sure if some of the features you're requesting are actually used for the type of program you're describing. But that mostly doesn't matter.
When you build a stand-alone JAR artifact with Maven, fixed classpath resources that need to be copied into the target jar should be placed in the src/main/resources directory subtree. All files and directories in that subtree are copied by the jar plugin verbatim to the target jar. That should be all you need for a standalone app using Hibernate.
An IDE is no substitute for an Intelligent Developer.
Joined: Dec 30, 2009
Ahh ... so easy it is and so blind am I ... sorry for that and thank you very much for your response.
I put ALL resources (hibernate.cfg.xml and mapping files *.hbm.xml) in the src/main/resources dir AND corrected the path to the mapping files given in hibernate.cfg.xml to point to the root and, voila, it works now: