Search code examples
spring-bootmavendependenciespom.xmldependency-management

What is the purpose of dependency management tag in pom.xml?


Can someone please explain what this dependency do under dependency management and after adding it why we don't need to mention version of our dependencies?

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

Solution

    • dependencyManagement makes them available, but you need to import them in every submodule you want them loaded into. Works as version control, and avoids a bloated project with all dependencies loaded in every module or child project.

    • dependencies loads them for every module or child who inherits them.