嘗試使用spring啓動應用程序與aws-s3連接。當我使用工廠方法'amazonS3Client':訪問密鑰不能爲空
進口org.springframework.cloud.aws.context.support.io.ResourceLoaderBeanPostProcessor
獲得AWS鍵不能爲空。
@Configuration
@EnableContextResourceLoader
@EnableContextCredentials
public class S3Configuration {
@Value("${cloud.aws.credentials.accessKey}")
private String ACCESS_KEY;
@Value("${cloud.aws.credentials.secretKey}")
private String SECRET_KEY;
@Value("${cloud.aws.region}")
private String region;
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
public AmazonS3Client amazonS3Client() {
return new AmazonS3Client(new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY));
}
@Bean
public ResourceLoaderBeanPostProcessor resourceLoaderBeanPostProcessor() {
return new ResourceLoaderBeanPostProcessor(amazonS3Client());
}
}
如果我不使用「ResourceLoaderBeanPostProcessor」類,然後AmazonS3Client對象被成功讀取性能形成application.properties創建。
有人能幫助我,我做錯了什麼?
謝謝,它解決了。 –