有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java重写S3Bucket中的文件在通过jar运行作业时不起作用,但在IDE(Eclipse)中起作用

我希望读取并覆盖S3bucket中的json文件。我已经使用Eclipse IDEMapReduce中实现了以下代码。我能够在S3Bucket中成功覆盖

我使用maven构建了jar,并在终端中运行了作业,此时我无法在S3bucket中覆盖。它也不会抛出任何异常

总之,

  • 当我通过eclipse运行作业时,我能够覆盖
  • 当我通过jar文件运行作业时,我无法覆盖S3Bucket中的文件

    AmazonS3 s3client = new AmazonS3Client(new PropertiesCredentials(
     S3Sample.class.getResourceAsStream("AwsCredentials.properties")));
    
     try {
         System.out.println("Uploading a new object to S3 from a file\n");
         File file = new File(uploadFileName);
    
         s3client.putObject(new PutObjectRequest(
                         bucketName, keyName, file));
    
      } catch (AmazonServiceException ase) {
    
         System.out.println("Caught an AmazonServiceException, which " +
        "means your request made it " +
        "to Amazon S3, but was rejected with an error response" +
        " for some reason.");
       // ... error handling based on exception details
    
      }
    

请告诉我如何进行这项工作


共 (0) 个答案