Search code examples
mavenmaven-bom

It is necessary to add dependencies to Maven BOM or only versions?


What is the right way to create maven BOM file? Should it include only versions or dependencies are also required. I mean two variants of BOM:

Var #1:

<properties>
    <javafx.version>23</javafx.version>
</properties>
<!-- no dependencyManagement section -->

Var #2:

<properties>
    <javafx.version>23</javafx.version>
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Solution

  • Variant 1 will not work because properties are not imported from BOMs, only dependencyManagement.

    So you need to use Variant 2.