aws sqs消息队列找不到AWSCredentials类错误

时间:2016-03-27 23:32:03

标签: java maven amazon-sqs

使用maven进行构建。测试Amazon SQS连接。 Java代码被编译但是当我运行它时收到AWSCredentials Class not found错误。我已经在java代码中导入了AmazonSQS。不知道为什么它会给我一个错误。

java -cp "./target/queue-service-1.0.0.jar"  com.example.TestSqsQueueService
    Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials
Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentials

在pom.xml中进行以下配置。

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

在main函数中使用以下Java代码并导入以下文件 package com.example;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.sqs.*;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.*;
import com.amazonaws.auth.AWSCredentials;
import java.util.*;
import java.util.Map.*;

public class TestSqsExample {

public static void main(String args[]) {
       BasicAWSCredentials awsCreds = new BasicAWSCredentials("XXXXXXXXX",  "XXXXXXXXXXXXXX");
     AmazonSQSClient s3Client = new AmazonSQSClient(awsCreds);

    System.out.println("hello world");

}
}

0 个答案:

没有答案