繁体   English   中英

AWS Lambda Java:Lambda 无法解压缩文件

[英]AWS Lambda Java: Lambda was not able to unzip the file

我正在尝试将 Java 与 AWS Lambda 结合使用。 我创建了一个包含所有依赖项的 jar 文件(使用 maven-assembly-plugin)。 上传后,我无法调用 lambda。 我收到错误Calling the Invoke API failed with message: Lambda was not able to unzip the file jar 文件为 11 MB。 我可以用java -jar执行 jar

需要告诉maven-assemply-plugin输出zip ,而不是jar (我什至不知道有区别!)

将此添加到其配置中:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-assembly-plugin</artifactId>
     ...
     <configuration>
         ...
         <formats>
            <format>zip</format>
         </formats>
     </configuration>
</plugin>

我遇到了这个问题,因为一个装有 Shade 插件的 JAR 生成了文件和目录META-INF\\version\\9

通过排除这些文件,JAR 可以再次运行。 以下是 maven-shade-plugin 的配置部分。

    <configuration>            
      <filters>
        <filter>
          <artifact>*:*</artifact>
          <excludes>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
            <exclude>META-INF/*.RSA</exclude>
            <exclude>META-INF/versions/9</exclude>
            <exclude>META-INF/versions/9/*</exclude>
          </excludes>
        </filter>
      </filters>
    </configuration>

遭受同样的问题。

通常,如果 lambda 函数的 .zip 或 .jar 文件大小在解压后超过50MB ,则会出现此错误

确保 lambda 函数代码的大小小于50MB

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM