0
我使用春季啓動1.5.1.RELEASE與春雲AWS 1.1.3.RELEASE將文件上傳到AWS的S3桶。春雲AWS與Transfermanager:無法完成轉移:連接池關閉
我想用TransferManager上傳文件到S3。 但不幸的是,我在上傳時收到以下錯誤消息,並且文件不會被上傳到S3:
2017-02-26 12:36:27.004 ERROR 32696 --- [ask-scheduler-8] o.s.integration.handler.LoggingHandler : com.amazonaws.AmazonClientException: Unable to complete transfer: Connection pool shut down
at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.unwrapExecutionException(AbstractTransfer.java:277)
at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.rethrowExecutionException(AbstractTransfer.java:261)
at com.amazonaws.services.s3.transfer.internal.UploadImpl.waitForUploadResult(UploadImpl.java:66)
at com.my.package.aws.S3Configuration.withTransferManager(S3Configuration.java:50)
at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
這是我的Java配置文件:
@EnableContextResourceLoader
@EnableContextCredentials(accessKey="XXXX", secretKey="YYYY")
@EnableAsync
@ComponentScan("com.my.package")
@EnableJpaRepositories(basePackages = "com.my.package.repository")
@EnableScheduling
@SpringBootApplication
public class S3UploadApplication {
public static void main(final String[] args) {
SpringApplication.run(S3UploadApplication.class, args);
}
}
而且配置Bean的S3有:
@Configuration
public class S3Configuration {
@Autowired
private AmazonS3Client amazonS3client;
public void withTransferManager() {
TransferManager transferManager = new TransferManager(this.amazonS3client);
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
Upload uploaded=transferManager.upload("myBucket","test.txt",new FileInputStream(new File("TestFile.txt")),objectMetadata);
uploaded.waitForCompletion();
transferManager.shutdownNow();
}
}
我也試過這個solution,那就是在這兩個豆類BasicAWSCredentials和AmazonS3Client EXP合法地進行配置,但仍顯示相同的錯誤。