gpt4 book ai didi

maven - AWS 的 joda-time 问题 (java.lang.NoSuchMethodError)

转载 作者:行者123 更新时间:2023-12-01 23:20:20 30 4
gpt4 key购买 nike

我遇到了 aws sdk 和 joda-time 的常见问题。即使互联网上有很多这样的问题,我仍然无法解决......

Exception in thread "main" java.lang.NoSuchMethodError: org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg/joda/time/format/DateTimeFormatter;
at com.amazonaws.auth.internal.AWS4SignerUtils.<clinit>(AWS4SignerUtils.java:26)
at com.amazonaws.auth.internal.AWS4SignerRequestParams.<init>(AWS4SignerRequestParams.java:85)
at com.amazonaws.auth.AWS4Signer.sign(AWS4Signer.java:168)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:814)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:11132)
at com.amazonaws.services.ec2.AmazonEC2Client.runInstances(AmazonEC2Client.java:10657)
at cloudSteuerung.AmazonWebServices.create(AmazonWebServices.java:33)
at de.bla.ccu.Test.main(Test.java:16)

检查maven的依赖关系树,我注意到几个joda依赖关系。 AWS似乎需要2.8.1版本,所以我在pom文件中明确添加了它,但错误仍然发生。我尝试了 joda 的几个版本,但似乎没有一个版本可以正常工作。谁能帮我?我只是想运行 AWS sdk EC2 示例...

dependency tree

最佳答案

我在使用 aws-java-sdk artifactId 声明我们的 AWS 依赖项时遇到了此问题。例如

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>x.y.z</version>
</dependency>

我们改为导入 aws-java-sdk-bom 依赖项 as recommended by Amazon ,例如

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>x.y.z</version>
<type>pom</type>
<scope>import</scope>
</dependency>

然后单独声明我们的组件依赖项,例如

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>

这使得 Maven 能够确定 aws-sdk 的正确 joda-time 依赖性并解决了问题。

关于maven - AWS 的 joda-time 问题 (java.lang.NoSuchMethodError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36358290/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com