0

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>
raman bhadauria
  • 145
  • 2
  • 11
  • 1
    Have you read e.g. https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html? – jonrsharpe Apr 02 '20 at 14:59
  • Does this answer your question? [Differences between dependencyManagement and dependencies in Maven](https://stackoverflow.com/questions/2619598/differences-between-dependencymanagement-and-dependencies-in-maven) – J Fabian Meier Apr 02 '20 at 16:19
  • JF Meier, the question you mentioned here talks about parent and child projects and usage of dependency management in the parent project. Here both dependency management and dependency are in same project. Hope I made my doubt clear. – raman bhadauria Apr 03 '20 at 16:25

1 Answers1

6
  • 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.

Hayi
  • 6,972
  • 26
  • 80
  • 139
Colon
  • 365
  • 1
  • 12