引入sdk maven
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
但是执行上传操作的时候却会报错,这是因为还缺少一个依赖:
报错如下:
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/HmacUtils
at com.qcloud.cos.auth.COSSigner.buildAuthorizationStr(COSSigner.java:91)
at com.qcloud.cos.auth.COSSigner.sign(COSSigner.java:53)
at com.qcloud.cos.COSClient.invoke(COSClient.java:501)
at com.qcloud.cos.COSClient.putObject(COSClient.java:821)
at com.thinkgem.jeesite.modules.dmeo.MyDemo.upload(MyDemo.java:51)
at com.thinkgem.jeesite.modules.dmeo.MyDemo.main(MyDemo.java:70)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.digest.HmacUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 6 more
缺少依赖如下
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>