3

Some dependency versions are not in so I've added the spring platform BOM, is the parent declaration still useful?

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.1.RELEASE</version>
</parent>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.spring.platform</groupId>
            <artifactId>platform-bom</artifactId>
            <version>1.1.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
  • 1
    I think that this is fine, if you're not working on a professional project. If it's meant to be professional level then you wouldn't want to have the spring-bom as your parent -- you'd have your own. – Software Engineer Jan 28 '15 at 19:24

2 Answers2

3

I personally prefer to use platform-bom as a parent, i.e.

<parent>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>1.1.1.RELEASE</version>
    <relativePath />
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

In this way I don't have to define spring-boot version number and it is automatically updated with newer version of spring platform and I don't have to worry about any inconsistencies.

See http://docs.spring.io/platform/docs/1.1.1.RELEASE/reference/htmlsingle/#appendix-dependency-versions for complete list of all managed dependencies.

EDIT: As pointed out by Andy Wilkinson, spring platform inherits spring-boot-starter-parent so all "sensible defaults" as described in http://docs.spring.io/spring-boot/docs/1.2.1.RELEASE/reference/htmlsingle/#using-boot-maven apply as well.

sodik
  • 4,675
  • 2
  • 29
  • 47
  • 2
    It's also worth noting that `platform-bom` inherits from `spring-boot-starter-parent` so, by using `platform-bom` as your parent, you also inherit Boot's plugin management, etc. – Andy Wilkinson Jan 29 '15 at 10:02
3

There is a important difference between importing a BOM (in the dependencyManagement section) and using a parent

The BOM imported in dependencyManagement only provides defaults for dependencies, but a Parent-way include the other sections too (plugins, plugin-managent, dependencies, dependencyManagement...)

So when you remove the parent spring-boot-starter-parent then you have to copy the the plugin-managent stuff you need first.

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • interesting :) I guess you are referring to http://docs.spring.io/spring-boot/docs/1.2.1.RELEASE/reference/htmlsingle/#using-boot-maven – sodik Jan 29 '15 at 08:22
  • @sodik: no special reference, just maven knowege – Ralph Jan 29 '15 at 12:37