gpt4 book ai didi

spring-cloud-stream - 无法从链中的任何提供商加载 AWS 凭证 Spring Cloud Stream Kinesis binder

转载 作者:行者123 更新时间:2023-12-01 19:33:45 24 4
gpt4 key购买 nike

如果不使用系统级别的默认配置,我将无法连接到 Spring Cloud Stream Kinesis binder (1.2.0.RELEASE) 中的 AWS kinesis。仅当系统已配置为使用默认配置文件并且访问 key ID 和 secret 访问 key 设置为 [默认] 配置文件时,应用程序才能工作。否则,它无法通过抛出此异常连接到 AWS 资源:

Caused by: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@3b2c8bda: Unable to load credentials from service endpoint, com.amazonaws.auth.profile.ProfileCredentialsProvider@688d619c: No AWS profile named 'default']
at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:136)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1225)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:801)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:751)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:744)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:3768)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3737)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeDescribeTable(AmazonDynamoDBClient.java:1836)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.describeTable(AmazonDynamoDBClient.java:1804)
at com.amazonaws.services.dynamodbv2.document.Table.describe(Table.java:137)
at org.springframework.integration.aws.metadata.DynamoDbMetadataStore.afterPropertiesSet(DynamoDbMetadataStore.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)

我尝试了以下选项,但没有一个对我有用:
  • 设置环境变量 AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
  • 设置 Java 系统属性 aws.accessKeyIdaws.secretKey
  • 套装cloud.aws.credentials.accessKeycloud.aws.credentials.secretKeyapplication.yml文件。
  • 最佳答案

    我解决了这个问题。

    我想 spring-cloud-starter-aws无法自动配置。
    所以我像这样以编程方式设置访问 key 和 secret key :

    @Configuration
    class AWSS3Configuration {

    @Value("\${cloud.aws.credentials.access-key}")
    val accessKey: String = ""

    @Value("\${cloud.aws.credentials.secret-key}")
    val secretKey: String = ""

    @Bean
    fun amazonS3(): AmazonS3 =
    AmazonS3ClientBuilder.standard()
    .withCredentials(AWSStaticCredentialsProvider(BasicAWSCredentials(accessKey, secretKey)))
    .build()

    }

    关于spring-cloud-stream - 无法从链中的任何提供商加载 AWS 凭证 Spring Cloud Stream Kinesis binder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57520314/

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