java服务在运行时抛出如下异常
EXCEPTION: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64(Ljava/lang/String;)[B java.lang.NoSuchMethodError:
后查明是包依赖冲突的问题,本来应该使用commons-codec:commons-codec,但实际上使用了org.apache.commons:com.springsource.org.apache.commons.codec
# mvn dependency:tree [INFO] +- commons-codec:commons-codec:jar:1.8:compile [INFO] +- org.apache.commons:com.springsource.org.apache.commons.httpclient:jar:3.1.0:compile [INFO] | +- org.apache.commons:com.springsource.org.apache.commons.codec:jar:1.3.0:compile [INFO] | /- org.apache.commons:com.springsource.org.apache.commons.logging:jar:1.1.1:compile
解决方法,依赖httpclient时将codec包排除掉
<dependency> <groupId>org.apache.commons</groupId> <artifactId>com.springsource.org.apache.commons.httpclient</artifactId> <version>3.1.0</version> <exclusions> <exclusion> <artifactId>com.springsource.org.apache.commons.codec</artifactId> <groupId>org.apache.commons</groupId> </exclusion> </exclusions> </dependency>