简体   繁体   English

使用基本凭证访问EC2实例

[英]Access EC2 Instance using Basic Credentials

I'm trying to use the Java SDK to programmatically stop an EC2 instance. 我正在尝试使用Java SDK以编程方式停止EC2实例。 I'm very new the AWS api, but what I'm trying to do should be very basic: 我是AWS API的新手,但是我想做的事情应该非常基础:

BasicAWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);

AmazonEC2Client ec2 = new AmazonEC2Client(credentials); //ERROR caused by this line

I've seen several examples of this, for example here . 我已经看到了几个这样的例子,例如在这里 I know the better way to do this is by using IAM roles, but I'm just trying to get something to work first. 我知道执行此操作的更好方法是使用IAM角色,但我只是想首先使某些事情起作用。 The line that creates the AmazonEC2 throws this error 创建AmazonEC2的行将引发此错误

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper at com.amazonaws.util.json.Jackson. 

I can't figure out why it's throwing a class definition not found error. 我不知道为什么它会抛出一个类定义未找到错误。

I figured out the issue. 我发现了问题。 Apparently the AWS library requires three more dependencies in fasterxml.jackson.core . 显然,AWS库在fastxml.jackson.core中还需要三个依赖关系。 Because I was using Ivy to configure these, I had to add these manually 因为我使用Ivy进行配置,所以必须手动添加

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM