Skip to content

What is the recommended way of overriding version of a dependency from parent pom?

I want to override the bouncy castle version from the parent POM. I know we can add the dependency explicitly like so:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpkix-jdk15on</artifactId>
    <version>1.69</version>
</dependency>

But this is not the recommended way, the recommended way is adding the version in the properties part of the POM, but I can’t seem to find the name of the version property for Bouncy castle.

Answer

but I can’t seem to find the name of the version property for Bouncy castle.

because it’s custom, you need to create it.

You could define a custom property under and refer to it from your dependency. The preferred approach is to place the property in the parent pom.

<properties>
    <bouncycastle.version>1.69</bouncycastle.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>${bouncycastle.version}</version>
    </dependency>
</dependencies>

There are some more ways you can check here to override verison