What is the purpose of the dependencyManagement
section in Maven?
A) To manage versions of dependencies in child projects
B) To configure Maven plugins
C) To define the project’s main dependencies
D) To specify the repository settings
Answer:
A) To manage versions of dependencies in child projects
Explanation:
The <dependencyManagement>
section in Maven is used to manage the versions of dependencies across multiple child projects. When a parent project defines a dependency in the <dependencyManagement>
section, child projects can inherit this dependency and its version without having to specify the version in their own pom.xml
files.
For example:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies>
</dependencyManagement>
In this example, the Spring Boot Web Starter dependency is managed by the parent project, and any child project can inherit this dependency without specifying the version.