Myna
Myna

Reputation: 559

Maven dependencies not being added to WEB-INF/lib

Fairly new to Spring, Maven, Tomcat and all, I am trying to set up a Spring Web Project in Eclipse, using Maven then deploy the project to Tomcat.

I am following this tutorial, suggested by a SOF member : http://www.beingjavaguys.com/2013/08/spring-maven-web-application-in-eclipse.html

I am having troubles to have Maven add the dependencies specified in pom.xml, to Tomcat's WEB-INF/lib. I have scrupulously followed the steps, but in the part "Run Spring Maven project in eclipse", I do not get the same deployment assembly screenshot. This is what I get :

Web deployment assembly in Eclipse, after running <code>mvn eclipse:eclipse -Dwtpversion=2.0</code>

I checked in Eclipse that WTP is here, and it is (Help -> Install new Software -> Link "what is installed?") However the version I see for m2e-wtp is 1.0.**. SO I tried to run the mvn eclipse:eclipse -Dwtpversion=1.0 command (using version 1.0 instead of 2.0) but still the same problem...

Anybody has had the same problem ? I have seen similar questions, tried what was suggested but nothing worked for me unfortunately. For example I went in Web Deployment Assembly and clicked Add -> Java Build Path Entries but I don't see a Maven Dependencies checkbox : what I see is a list of entries of the form M2_REPO/.../...

Happy Holidays everyone, and thanks in advance for any help on this Myna

Upvotes: 7

Views: 22691

Answers (4)

Alex Mi
Alex Mi

Reputation: 1459

I have just had the same problem after improting a new maven web project in my newly created workspace. I checked everything mentioned above: by @Eugen, @lucky, @Cary - all of this was already presented in my project.

I solved my problem by right-clikcing on my it and selecting Maven-->Update Project

Upvotes: 1

Cary
Cary

Reputation: 96

Open your project folder and find the .classpath file,edit it and add follow code

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

Upvotes: 4

Lucky
Lucky

Reputation: 17345

It looks like you don't have Maven installed in your eclipse version you use. However you can install Maven Integration for Eclipse from the Eclipse Market place. Just Go to Help => Eclipse MarketPlace and Type Maven Integration and install the Maven Integration for eclipse.

Once you are done eclipse will restart and you will be able to see your jars in the Dependency management as Maven Dependencies.

Visit this url for more info Hope this helps. m2eclipse

Upvotes: 0

Eugen
Eugen

Reputation: 8783

Looks like your "Deployment Assembly" is missing the Maven Dependencies being added to the packaging structure of your project. The way this should look is:

enter image description here

The way to add that in is:
- click on Add
- select Java Build Path Entries
- select Maven Dependencies
- Finish

That should add your Maven Dependencies into WEB-INF/lib. In case your project structure is not standard, you can also edit that path by double-clicking inside your Deploy Path column - in this case, on WEB-INF/lib.

Hope that helps.

Upvotes: 15

Related Questions