网站开发QQ第三方登陆报错:cannot find symbol

环境:mac os 10.9.5

IDE:eclipse Kepler

报错初因:网站接入QQ第三方登陆。java开发,需要使用sdk4j.jar(官网),linux下ant 打包报错

报错内容:

 build-project:
    [javac] location: class org.apache.commons.codec.binary.Base64
    [javac]         return Base64.encodeBase64URLSafeString(input);
    [javac]                      ^
    [javac] /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/src/com/tywire/tadu/wap/utils/EncodeUtils.java:19: cannot find symbol
    [javac] symbol  : method encodeHexString(byte[])
    [javac] location: class org.apache.commons.codec.binary.Hex
    [javac]         return Hex.encodeHexString(input);
    [javac]                   ^
    [javac] /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/src/com/tywire/build-project:
     [echo] tadu-wap: /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/build.xml
    [javac] /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/build.xml:66: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 282 source files to /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/WebRoot/WEB-INF/classes
    [javac] /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/src/com/tywire/tadu/wap/utils/CryptoUtils.java:357: cannot find symbol
    [javac] symbol  : method encodeBas tadu/wap/utils/EncodeUtils.java:44: cannot find symbol
    [javac] symbol  : method encodeBase64URLSafeString(byte[])
    [javac] location: class org.apache.commons.codec.binary.Base64
    [javac]         return Base64.encodeBase64URLSafeString(input);
    [javac]                      ^
    [javac] /home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/src/com/tywire/tadu/wap/utils/EncodeUtils.java:51: decodeBase64(byte[]) in org.apache.commons.codec.binary.Base64 cannot be applied to (java.lang.String)
    [javac]         return Base64.decodeBase64(input);
    [javac]                      ^
    [javac] Note:/home/jenkins/.jenkins/jobs/tadu_dubbo-wap/workspace/src/com/tywire/tadu/wap/utils/HttpUtil.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 4 errors

   ps:在eclipse上,打包不会报错,一切顺利,项目部署也能使用。(不知道为啥,同求解)

问题原因:jar包内类冲突。(提示信息里提到了,Base64,Hex)sdk4j.jar里面包含并使用了.apache.commons.codec。我的项目里面也使用了org.apache.commons.codec的jar。

 

解决问题:使用winRAR打开sdk4j.jar,然后删除冲突的文件(或者目录,根据冲突内容自己定,我是删了commons目录)。然后删除冲突的sdk4j.jar重新放入项目,打包成功

 

你可能感兴趣的:(网站开发QQ第三方登陆报错:cannot find symbol)