AWS开发工具包中的java.lang.NoSuchMethodError

时间:2018-07-03 16:47:03

标签: java maven aws-sdk

我正在尝试使用以下代码将图像上传到Amazon S3存储桶:

   AmazonS3 s3Client = AmazonS3ClientBuilder.standard()

   .withRegion("us-east-1")
   .withCredentials(credentialsProvider)
   .build();

但是,Eclipse抛出以下异常:

Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:537)
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:448)
    at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:51)
    at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
    at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
    at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
    at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
    at com.amazonaws.client.builder.AwsClientBuilder.getRegionObject(AwsClientBuilder.java:249)
    at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:238)
    at order_fulfilment.amazon.AmazonS3API.perform(AmazonS3API.java:68)
    at amzn.Main.main(Main.java:126)

基于this线程,Jackson版本似乎存在问题。但是,我尝试了所有版本的Jackson(包括线程建议的版本2.6.7和2.6.6。)都无济于事。

我能够使用以下代码确认Jackson版本正确:

System.out.println(com.fasterxml.jackson.databind.ObjectMapper.class.getProtectionDomain().getCodeSource().getLocation());

根据thisthis线程在stackoverflow上的建议。

我在做什么错了?

所有依赖项:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>amz</groupId>
    <artifactId>amz</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>lib</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>javax.mail-api</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>ru.yandex.qatools.ashot</groupId>
            <artifactId>ashot</artifactId>
            <version>1.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.5.3</version>
        </dependency>





        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-sheets</artifactId>
            <version>v4-rev520-1.23.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.apache.geronimo.gshell.support</groupId>
            <artifactId>gshell-io</artifactId>
            <version>1.0-alpha-2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>


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


    </dependencies>
</project>

注意::我对每种依赖关系使用了许多不同的版本(这是我尝试的最新版本),但是它们都导致相同的错误。

0 个答案:

没有答案