使用maven进行构建。测试amazon sqs连接。java代码得到编译,但当我运行它时收到一个awscredentials类notfound错误。我已经在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>
在主函数中有下面的java代码并导入下面的文件包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");
}
}
暂无答案!
目前还没有任何答案,快来回答吧!