Where should a dependency version be defined so that all projects inheriting the BOM share the same version?

Prepare for the MuleSoft Developer 2 Certification Exam. Access practice quizzes featuring flashcards and multiple choice questions with explanations. Get confident and ready for your certification success!

Multiple Choice

Where should a dependency version be defined so that all projects inheriting the BOM share the same version?

Explanation:
Centralize versions where the build can apply them automatically: define the dependency versions in the dependencyManagement section of the BOM’s parent POM. This creates a single source of truth for versions that will be applied to all projects that import or inherit the BOM. When a child project declares a dependency without specifying a version, Maven will resolve the version from the BOM’s dependencyManagement, ensuring consistency across all inheriting projects. Example in the BOM: dependencyManagement dependencies dependency groupId: org.example artifactId: my-lib version: 1.2.3 Then a child can simply declare the dependency without a version: dependency groupId: org.example artifactId: my-lib Defining versions in a separate properties module or in each child POM would dilute this consistency, and placing versions in a transitive POM wouldn’t provide a centralized, shared version baseline across multiple projects.

Centralize versions where the build can apply them automatically: define the dependency versions in the dependencyManagement section of the BOM’s parent POM. This creates a single source of truth for versions that will be applied to all projects that import or inherit the BOM. When a child project declares a dependency without specifying a version, Maven will resolve the version from the BOM’s dependencyManagement, ensuring consistency across all inheriting projects.

Example in the BOM:

dependencyManagement

dependencies

dependency

groupId: org.example

artifactId: my-lib

version: 1.2.3

Then a child can simply declare the dependency without a version:

dependency

groupId: org.example

artifactId: my-lib

Defining versions in a separate properties module or in each child POM would dilute this consistency, and placing versions in a transitive POM wouldn’t provide a centralized, shared version baseline across multiple projects.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy