无法从类路径上的/AwsCredentials.properties 文件加载 AWS 凭证 [英] Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath

查看:26
本文介绍了无法从类路径上的/AwsCredentials.properties 文件加载 AWS 凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此代码设置类路径

AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();
ec2 = new AmazonEC2Client(credentialsProvider);

以下是 AwsCredentials.properties 文件的格式

Below is the format for AwsCredentials.properties file

# Fill in your AWS Access Key ID and Secret Access Key
# http://aws.amazon.com/security-credentials
accessKey = keyHere
secretKey = secretKeyHere

以下是我遇到的异常

Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath

    at com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider.getCredentials(ClasspathPropertiesFileCredentialsProvider.java:81)
    at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:8359)

推荐答案

您收到此异常是因为您的 AWS 开发工具包无法加载您的凭证.您应该做的是转到首选项,然后转到 AWS 并添加您的密钥和访问密钥.这样您的项目就可以检索这两个密钥.

You are getting this exception because your AWS SDK is unable to load your credentials. What you should do is goto Preferences then goto AWS and add your secret key and access key. So that your project can retrieve both keys.

这篇关于无法从类路径上的/AwsCredentials.properties 文件加载 AWS 凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆