Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven dependency for whole org.springframework

How to set Maven dependency for all org.springframework ?

I mean, how to do it in couple lines,instead of providing dependency for every module,e.g.:

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

etc..

thank you for help

like image 521
sergionni Avatar asked Jun 18 '11 19:06

sergionni


People also ask

What is Maven dependency for Spring?

Spring MVC With Maven The spring-web dependency contains common web specific utilities for both Servlet and Portlet environments, while spring-webmvc enables the MVC support for Servlet environments.

How do you add Spring-core dependency in POM XML?

Open the Maven Project Object Model (POM) file and select the Dependencies tab. Use the The Central Repository website to find the Dependency Information for spring-core and Spring-context artifacts (jar files). Add… both Spring Dependencies to the pom.

What is Spring-core dependency?

The Spring-Core module is responsible for injecting dependencies through either Constructor or Setter methods. The design principle of Inversion of Control emphasizes keeping the Java classes independent of each other and the container frees them from object creation and maintenance.


1 Answers

This answer is aimed to newer version 4.X.X

If you want to handle versions of dependencies more efficiently use this code before your <dependencies></dependencies> tags.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.2.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Benefit of using the BOM is that you no longer need to specify the version of dependency. So your dependencies should looks like:

<dependencies>
    <!-- Spring framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
    </dependency>
</dependencies>
like image 108
Daniel Perník Avatar answered Sep 23 '22 13:09

Daniel Perník