Spring 在这个项目中,s3Client是如何自动连接的?

Spring 在这个项目中,s3Client是如何自动连接的?,spring,amazon-web-services,spring-boot,amazon-s3,Spring,Amazon Web Services,Spring Boot,Amazon S3,我正在编写一个Spring应用程序,希望在其中使用AWSS3客户端。我需要做的就是生成签名的URL。使用S3客户机的代码很简单,我已经编写了它,但是我正在尝试找出正确的方法来实例化它,就像Spring方法一样 我发现这似乎满足了我的需要。在FileArchiveService.java上,它有: 当我将这些行添加到我的项目中时,我预期会出现以下错误: Exception encountered during context initialization - cancelling refresh

我正在编写一个Spring应用程序,希望在其中使用AWSS3客户端。我需要做的就是生成签名的URL。使用S3客户机的代码很简单,我已经编写了它,但是我正在尝试找出正确的方法来实例化它,就像Spring方法一样

我发现这似乎满足了我的需要。在
FileArchiveService.java
上,它有:

当我将这些行添加到我的项目中时,我预期会出现以下错误:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'screenshotsController': Unsatisfied dependency expressed through field 's3Client'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.amazonaws.services.s3.AmazonS3Client' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
我搜索了SpringBootAWS试图找出这个bean是如何提供的,但我找不到它。我包含了相同的依赖项,
org.springframework.cloud:springcloudaws context:1.2.1.RELEASE
,但这还不够

你知道那个项目是怎么做的,或者我应该怎么做吗

我尝试处理aws-config.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aws-context="http://www.springframework.org/schema/cloud/aws/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
                           http://www.springframework.org/schema/cloud/aws/context
                           http://www.springframework.org/schema/cloud/aws/context/spring-cloud-aws-context-1.0.xsd">
    <aws-context:context-credentials>
        <aws-context:simple-credentials access-key="${accessKey:}" secret-key="${secretKey:}"/>
    </aws-context:context-credentials>
    <aws-context:context-resource-loader/>
</beans>

但我仍然会遇到同样的错误。

我觉得配置文件和spring cloud aws deps一起公开了一个AmazoneS3Client beanAwsResourceConfig.java似乎是针对Amazon数据库的。我尝试添加另一个来获取S3客户机,但没有成功。同样的错误。此外,我没有任何其他XML文件,因此,我不确定是否遗漏了其他内容。我试图坚持使用Java而不是XML。我指的是
AwsResourceConfig
中的
@ImportResource(“classpath:/aws config.XML”)
。您可以放弃与RDS相关的注释。您可以先尝试使用XML,然后再使用类似的选项替换XML。我觉得配置文件和spring cloud aws deps一起公开了AmazoneS3Client beanAwsResourceConfig.java似乎适用于Amazon数据库。我尝试添加另一个来获取S3客户机,但没有成功。同样的错误。此外,我没有任何其他XML文件,因此,我不确定是否遗漏了其他内容。我试图坚持使用Java而不是XML。我指的是
AwsResourceConfig
中的
@ImportResource(“classpath:/aws config.XML”)
。您可以放弃与RDS相关的注释。您可以先尝试使用XML,然后使用类似的选项替换XML。
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aws-context="http://www.springframework.org/schema/cloud/aws/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
                           http://www.springframework.org/schema/cloud/aws/context
                           http://www.springframework.org/schema/cloud/aws/context/spring-cloud-aws-context-1.0.xsd">
    <aws-context:context-credentials>
        <aws-context:simple-credentials access-key="${accessKey:}" secret-key="${secretKey:}"/>
    </aws-context:context-credentials>
    <aws-context:context-resource-loader/>
</beans>
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource("classpath:/aws-config.xml")
public class AwsResourceConfig {

}