gpt4 book ai didi

java - 无法从类路径上的/AwsCredentials.properties 文件加载 AWS 凭证

转载 作者:IT老高 更新时间:2023-10-28 20:43:35 26 4
gpt4 key购买 nike

使用此代码设置类路径

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

以下是 AwsCredentials.properties 文件的格式

# 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)

最佳答案

我使用不同的方法建立了联系:

BasicAWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
AmazonDynamoDBClient client = new AmazonDynamoDBClient(credentials).withRegion(Regions.US_EAST_1);
DynamoDB dynamoDB = new DynamoDB(client);

访问 key 和 secret key 可以在 Identity and Access Management 中创建安慰。希望对你有帮助...

关于java - 无法从类路径上的/AwsCredentials.properties 文件加载 AWS 凭证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22588733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com