Updated on 2022-07-11 GMT+08:00

An Error Occurred When Building a JAR Package

Question

When the sample code is compiled using Maven to build a JAR package, the error message "Could not transfer artifact org.apache.commons:commons-crypto:pom:${commons-crypto.version}" is displayed and the package building fails.

Answer

The hbase-common module depends on commons-crypto. In the pom.xml file of hbase-common, the ${commons-crypto.version} variable is used to introduce commons-crypto. The parsing logic of this variable is as follows: If the OS is AArch64, the value is 1.0.0-hw-aarch64. If the OS is x86_64, the value is 1.0.0. If Maven fails to parse the variable using the OS due to incorrect configuration in the compilation environment, you can manually modify the pom.xml file to prevent correct compilation.

In the pom.xml file, manually change the dependency of the hbase-common module to the following to exclude the commons-crypto dependency:

<dependency>
    <groupId>org.apache.hbase</groupId>
    <artifactId>hbase-common</artifactId>
    <version>${hbase.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-crypto</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Manually add the commons-crypto dependency of the specified version. Enter a correct version based on the OS architecture (x86_64 or AArch64).

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-crypto</artifactId>
    <version>1.0.0</version>
</dependency>