Maven BOM [Bill Of Materials] Dependency

15,725

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.

Share:
15,725

Related videos on Youtube

Ajeet Deginal
Author by

Ajeet Deginal

Updated on July 22, 2020

Comments

  • Ajeet Deginal
    Ajeet Deginal almost 4 years

    I am not understanding what is the purpose of bom object? and I am working on Spring 3.2.8 version and with JBoss server, so which bom dependency I need to use? When I mention the following dependency in pom.xml:

    <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>4.0.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
    </dependency>
    

    Does the jar file gets downloaded into my Maven Dependencies?

    • Jesper
      Jesper almost 8 years
      The documentation answers your question: Maven "Bill Of Materials" Dependency. If you want to use Spring 3.2.8, then obviously you need to import the POM for Spring 3.2.8 and not Spring 4.0.1...
    • Ajeet Deginal
      Ajeet Deginal almost 8 years
      Thank you for reply, actually my application is working fine on tomcat web server, now I have to make to run on JBoss server. What all the changes I suppose to make? In terms of configuration and dependencies?
  • Ajeet Deginal
    Ajeet Deginal almost 8 years
    Thank you for the explanation.
  • ses
    ses over 6 years
    seems there is a problem to import the .. bom' properties though, - to the place/project where we import
  • David Ferreira
    David Ferreira over 5 years
    What are the defaults for <type> and <import> for those maven dependencies in the <dependencyManagment> tag?
  • Anton Koscejev
    Anton Koscejev over 5 years
    Default type is jar, default scope is compile, there's no import tag. For more info see maven.apache.org/guides/introduction/…
  • kaushalpranav
    kaushalpranav about 4 years
    I spent a day putting the bom in the dependency management section and hoping that maven would download all the jars in the bom. Only after I read youe answer, I realised, we have to put the dependencies we need ourselves into the pom along with bom. The only help bom does is to maintain the version of the jars. Thanks for your explanation.