Search code examples
javaeclipsespringmavenm2eclipse

adding spring resources to eclipse


I'm struggling with adding spring framework libaries to my eclipse (with maven plug-in m2eclipse) How can I achieve it in easiest way and why is it so complicated for a newbe user? It's really frustrating that I can't move on with thing that simple like this.

Main goal is add spring libaries to my pom.xml file in depedencies tab in my dynamic web project in eclipse. Pom.xml is generated thanks to maven plug-in.

First of all I moved to the Eclipse Marketplace and installed Spring Tool Suite for Eclipse Kepler 4.3 and the result is nothing - still can't add libaries. Second attempt was installing the same suite for my whole windows, nothing worked so far.

Sample screenshot (all I can add is this):

enter image description here

Where is spring-web, spring-context, spring-webmvc etc. ? For me it's night and I don't have fresh eye on it but what am i missing here?


Solution

  • I have been using the Spring Framework and Java within Eclipse for a while now. And to be completely honest, the UI for pom.xml completely sucks. Just avoid the Eclipse UI for Maven and manipulate the raw XML. It is very intuitive and powerful.

    So if you want to add a dependency, start using mvnrepository. From there you can get all the dependency snippets you need.

    For 'spring-web' insert

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.2.4.RELEASE</version>
    </dependency> 
    

    In the <dependencies></dependencies> section. And you are set.

    The same can be done for context and webmvc.

    Just for convenience here is spring-webmvc:

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.0.3.RELEASE</version>
    </dependency>
    

    and here is spring-context

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.0.3.RELEASE</version>
    </dependency>