编辑:
public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
System.out.println("debug1");
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer("key","secret");
System.out.println("debug2");
...}
嗨,当我尝试运行此脚本时,我得到以下响应:
调试1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at oauth.signpost.signature.OAuthMessageSigner.<init>(OAuthMessageSigner.java:37)
at oauth.signpost.signature.HmacSha1MessageSigner.<init>(HmacSha1MessageSigner.java:30)
at oauth.signpost.AbstractOAuthConsumer.<init>(AbstractOAuthConsumer.java:65)
at oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.<init>(CommonsHttpOAuthConsumer.java:30)
at mein.tester.main(tester.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more
第 21 行是前一行
System.out.println("debug2");
好吧,我可以轻松地在 Eclipse 中编译代码,并且添加了 2 个 Signpost 库以及 common-codec.jar 作为外部库,正如我在另一篇文章中所读到的那样。但是,我如何使其在运行时可用?(我确实喜欢发布“将其添加到 WEB-INF/lib ”-> 我创建了该文件夹并添加了 jar -我还尝试了 defaultoauthconsumer -> 相同的错误