23

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?

Ajeet Deginal
  • 241
  • 1
  • 2
  • 7
  • 1
    The documentation answers your question: [Maven "Bill Of Materials" Dependency](http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#overview-maven-bom). 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... – Jesper Jul 21 '16 at 06:42
  • 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 Jul 21 '16 at 12:27

1 Answers1

54

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.

Anton Koscejev
  • 4,603
  • 1
  • 21
  • 26
  • Thank you for the explanation. – Ajeet Deginal Jul 21 '16 at 12:50
  • seems there is a problem to import the .. bom' properties though, - to the place/project where we import – ses Sep 12 '17 at 17:45
  • What are the defaults for `` and `` for those maven dependencies in the `` tag? – David Ferreira Nov 12 '18 at 04:03
  • Default type is `jar`, default scope is `compile`, there's no `import` tag. For more info see https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html – Anton Koscejev Nov 13 '18 at 17:20
  • 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. – kaushalpranav Mar 07 '20 at 17:05