Skip to content
Advertisement

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.

Advertisement

Answer

It is up to you to create and name such property.

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

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

Refer to the reference documentation of Maven POM: Properties

Advertisement