Reputation: 5565
I have a Spring MVC project in Eclipse Galileo.
Its depenedencies are specified in pom.xml.
When I type mvn eclipse:eclipse
, depenedencies are specified as links in Eclipse build path.
But when I try to run this app on server (in Eclipse, run -> run on server) the dependencies do not exist in the class path and that's why I get classDefNotFound error.
Is there any way to fix this problem?
Thanks a lot!
Upvotes: 0
Views: 3933
Reputation: 21
I had a similar issue with a maven project on IRAD. Right click on the War project, select properties. Under 'Java EE Module Dependencies' select the check box besides 'Maven Dependencies'. This should copy the lib folder to the target location on server during deploy.
I am Using IRAD, so not sure if this is specific to IRAD or is available on Eclipse.
Upvotes: 1
Reputation: 68268
I suggest that you take a look at M2Eclipse. It provides a classpath container with the project's maven dependencies and has generally better integration with Eclipse.
Its main features are:
The maven-eclipse-plugin is scheduled to be deprecated and later on retired so it would be wise to look into something which will be maintained in the near future.
Upvotes: 1
Reputation: 570295
How to copy dependencies into WEB_INF/lib folder in Spring project with Maven?
There is no need to do that. And that would just be an horrible workaround. Fix the root cause of the problem.
I have a Spring MVC project in Eclipse Galileo. Its dependencies are specified in pom.xml. When I type mvn eclipse:eclipse, dependencies are specified as links in Eclipse build path.
Weird, that's not what I get. Can you show the content of your .classpath
? A typical .classpath
generated by the Maven Eclipse Plugin looks like this:
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
...
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
I don't see any "link" here. Is M2_REPO
defined in your environment?
But when I try to run this app on server (in Eclipse, run -> run on server) the dependencies do not exist in the class path and that's why I get classDefNotFound error
I think something else is wrong. But copying dependencies into WEB-INF/lib
is certainly not the right way to fix the problem.
Upvotes: 3