Maven BOM [Bill Of Materials] Dependency

What is the purpose of bom object?

Maven parent-child relationship is very handy for managing dependencies of multiple projects in a single place. However, Maven projects can have only one (direct) parent. So imports were introduced for dependency management to allow using several projects for managing your dependencies. With an import you can define a single dependency like this and get multiple dependencies managed – handy! Although you could import any project, BOM is a special project designed to be used for imports like this. Usually a BOM project will have very little defined besides dependencyManagement section, and will not have any unrelated dependencies, to avoid affecting your main project too much.

Which bom dependency I need to use?

BOM is not a requirement, you don’t need to use either. Instead, you could define all managed dependencies in dependencyManagement section yourself. These can include Spring, JBoss and any other dependencies. BOM, however, simplifies this for you significantly. You can add as many BOMs as you want, so add both! But as @Jesper mentions, don’t forget to use correct versions. When using multiple BOMs their order will matter if they both reference a common dependency.

Does the jar file gets downloaded into my Maven Dependencies?

Notice BOM is <type>pom</type>, not the default jar. So there’s no jar to be downloaded. A single pom.xml file will be downloaded and read by Maven.

Leave a Comment