我正在尝试为托管在云上的Spring引导maven应用程序(Pivotal Web Services)提供凭据,以便能够上传到Amazon S3。但是,每次我尝试使用以下命令获取凭据时:
DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain();
TransferManager transferManager = new TransferManager(credentialProviderChain.getCredentials());
它说
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
[Request processing failed; nested exception is com.amazonaws.AmazonClientException: Unable
to load AWS credentials from any provider in the chain] with root cause
2016-01-28T23:55:38.55+0000 [APP/0] OUT com.amazonaws.AmazonClientException:
Unable to load AWS credentials from any provider in the chain
我是否应该在beans.xml或application.properties文件中定义我的凭据有点困惑。但我试过两个都无济于事。有人能指出我正确的方向吗?
答案 0 :(得分:11)
AWS凭证提供程序链,按此顺序查找凭据:
此处提供更多通用文档:http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/credentials.html
答案 1 :(得分:3)
这种方法有效:
$ export AWS_ACCESS_KEY_ID=...
$ export AWS_SECRET_ACCESS_KEY=...