Search code examples
spring-bootmavenversionpom.xmlbyte-order-mark

Maven property overriding conflict between parent/bom


I am currently facing an issue with my maven configuration. I was thinking it will work in a way where versions in MyBom will have higher priority on the grand-grand-parent defined versions.

This is the setup :

enter image description here

In spring-dependencies, I have this version <atomikos.version>4.0.6</atomikos.version>. In myBom, I have this version <atomikos.version>5.0.106</atomikos.version>.

Both spring-dependencies and MyBom have the

<dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jta</artifactId>
        <version>${atomikos.version}</version>
</dependency>

I have imported the bom as usual in "MyParent":

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.test</groupId>
        <artifactId>myBom</artifactId>
        <version>${myBom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

Finally, in "MyProject", when I am showing the effective pom, it uses the version 4.0.6 coming from the spring-dependencies.

I was expecting the version to be 5.0.106 as the bom redefine it in a sublayer.

Note that it can work with any dependency which is common between bom and parent.

So, currently, my only viable solution is to manually set the the version in "MyParent" which is making the creation of "MyBom" useless...

Can you confirm what is correct ? My assumption (meaning I have a misconfiguration somewhere) or the current behavior, meaning "MyBom" is worthless.


Solution

  • This is not possible to override parents version from "MyBom" project. The only solution is to remove the spring-boot-starter-parent as parent and import the spring-dependencies at same level of "MyBom" import.

    I found the solution but I would like to thank @J Fabian Meyer to also point the correct solution.