java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64

后端 未结 3 815
情话喂你
情话喂你 2020-12-06 02:02

Here I\'m passing three parameters to this sign method. In this line

signature = new String(Base64.encodeBase64(mac.doFinal(data.getBytes(UTF_8_Encod

相关标签:
3条回答
  • 2020-12-06 02:10

    There could be Two Reason for that:

    First Reason: 1. The jar itself is not added in the pom.xml. In that case, add the dependency version in the pom.xml which has the class for which you are getting error

    Second Reason: When there are multiple jars added in the project and the jar version which is near to the project doesn't have that class. You can check the nearest jar in your project below command

    mvn dependency:tree -Dverbose -Dincludes=jar-name-casuing-conflict
    

    Once you identify the Jar version which has that class. You can resolve by adding that jar directly in your project pom.xml

    or You can exclude the jar that is nearer to your project which doesn't has that class and can point to another jar in the project.

    Example: it will exclude the jar in the project "org.cassandraunit" then it will see the immediate next jar that's close to the project will be used in your project

       <dependency>
                <groupId>org.cassandraunit</groupId>
                <artifactId>cassandra-unit</artifactId>
                <version>3.1.3.2</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-lang3</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
    0 讨论(0)
  • 2020-12-06 02:11

    just add commons-codec.jar into your classpath

    0 讨论(0)
  • 2020-12-06 02:12

    when you have error you can get all jar in picture,then your project will be ok.

    0 讨论(0)
提交回复
热议问题