无法为AWS Java编译示例项目

时间:2018-04-11 18:37:49

标签: java amazon-web-services

我正在尝试学习AWS SDK for Java。所以,我建立了一个亚马逊帐户并转到link

我下载了示例项目,创建了我的凭证文件,然后尝试编译并运行示例。

我第一次这样做时,收到了错误

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.

所以我改变了我的pom.xml文件:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

到此:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

之前的错误消失了,取而代之的是这个新错误:

[WARNING] 
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    at com.amazonaws.util.Base64.encodeAsString (Base64.java:36)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:70)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:58)
    at com.amazonaws.services.s3.internal.S3Signer.sign (S3Signer.java:127)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest (AmazonHttpClient.java:652)
    at com.amazonaws.http.AmazonHttpClient.executeHelper (AmazonHttpClient.java:460)
    at com.amazonaws.http.AmazonHttpClient.execute (AmazonHttpClient.java:295)
    at com.amazonaws.services.s3.AmazonS3Client.invoke (AmazonS3Client.java:3697)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:788)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:713)
    at com.amazonaws.samples.S3Sample.main (S3Sample.java:86)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    at java.net.URLClassLoader.findClass (URLClassLoader.java:466)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:566)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:499)
    at com.amazonaws.util.Base64.encodeAsString (Base64.java:36)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:70)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:58)
    at com.amazonaws.services.s3.internal.S3Signer.sign (S3Signer.java:127)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest (AmazonHttpClient.java:652)
    at com.amazonaws.http.AmazonHttpClient.executeHelper (AmazonHttpClient.java:460)
    at com.amazonaws.http.AmazonHttpClient.execute (AmazonHttpClient.java:295)
    at com.amazonaws.services.s3.AmazonS3Client.invoke (AmazonS3Client.java:3697)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:788)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:713)
    at com.amazonaws.samples.S3Sample.main (S3Sample.java:86)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.231 s
[INFO] Finished at: 2018-04-11T11:34:55-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project aws-java-sample: An exception occured while executing the Java class. null: InvocationTargetException: javax/xml/bind/DatatypeConverter: javax.xml.bind.DatatypeConverter -> [Help 1]

我对这一切都很陌生,而且我一直在谷歌上搜索,试图找到没有运气的答案。对于那些了解这类事情的人,我确信答案非常明显。如果你能指出我正确的方向,我真的很感激。

0 个答案:

没有答案