Spring boot Springboot注释@Bean与方法参数一起使用

Spring boot Springboot注释@Bean与方法参数一起使用,spring-boot,annotations,Spring Boot,Annotations,所以我在查看下面的代码片段时遇到了一个问题——如何在上下文容器中初始化这个Bean?是使用参数调用的方法。顺便说一句,这个代码段出现在AppConfig文件中。有人能帮我理解它吗 @Bean public AmazonS3 amazonS3Client(AWSCredentialsProvider credentialsProvider, @Value("${cloud.aws.region.static}") St

所以我在查看下面的代码片段时遇到了一个问题——如何在上下文容器中初始化这个Bean?是使用参数调用的方法。顺便说一句,这个代码段出现在AppConfig文件中。有人能帮我理解它吗

 @Bean
    public AmazonS3 amazonS3Client(AWSCredentialsProvider credentialsProvider,
                                   @Value("${cloud.aws.region.static}") String region) {
        return AmazonS3ClientBuilder
                .standard()
                .withCredentials(credentialsProvider)
                .withRegion(region)
                .build();
    }

是的,容器将尝试查找
AWSCredentialsProvider
依赖项,并将其作为参数传递给
amazonS3Client
方法。但是,您应该使用
@Configuration
注释包含此方法的
类。