I tried it first hoping maven would copy the necessary jars into the WEB-INF/lib directory automagically. Perhaps I need to insert a special clause in the pom.xml? I later tried manually copying the jar files into the WEB-INF/lib (like the tutorial said to do) and this did not seem to help... So maybe this is the wrong directory? I was hoping to make maven copy to the correct directory (what is the correct directory?) so jetty can load the spring classes. How do I make Maven deploy a WAR file with the spring jars? Is WEB-INF/lib the correct directory? (Do I need to post that question separately in the JEE/Servlet forum?)
I was also studying the pom.xml for http://www.objectdb.com/tutorial/jpa/eclipse/web. The downloadable source code (as opposed to the source code in the text) actually works and I cannot figure out how or why the necessary jar files are eventually put in the WAR files so jetty can call spring to run the servlet. How does this work? Where in the pom.xml is maven instructed to copy the required jar files to the WAR file? Does it have to do with the "scope" feature of the dependency?
The tutorial is wrong because it's not a maven tutorial. To add dependencies into a maven, you have to add the dependencies into the pom.xml. You shouldn't add it to eclipse. When you add it it pom.xml, Maven will automatically include the dependencies into your compile path, and also when you package the war, it will automatically put the dependencies into the WEB-INF/lib folder.
By adding the dependent libraries manually into Eclipse, you are circumventing Maven. Hence, Maven doesn't package it for you.
Siegfried Heintze
Ranch Hand
Joined: Aug 11, 2000
Posts: 359
posted
0
Oh yeah -- Sorry I did not make myself clear. I added the dependencies using the maven plugin for eclipse. When that did not work I tried manually adding them to the WEB-INF/lib directory. The first tutorial was not a maven tutorial and I was trying to use maven with it. So how does maven know how to copy the jar files to the WAR?
Jars that are declared as Maven dependencies in the POM will automatically be copied from the maven repository (cache) into the target WAR's WEB-INF/lib directory as long as they have the default (compile) scope.
Customer surveys are for companies who didn't pay proper attention to begin with.