构建AWS Lambda jar [英] Building AWS Lambda jar
问题描述
创建AWS Lambda jar的标准做法是什么。
What is the standard practice for creating AWS Lambda jar.
我们是否应该将依赖项作为jar文件包装在zip文件中,或者是否应该将所有依赖项解包并作为类包含在内。
Should we bundle the dependencies as jars within the zip file or should the dependencies be unjarred and included as classes.
据我所知,这是第一个适用的选项,但是当我遵循缩略图的AWS教程并且最终创建了一个有依赖类的jar(比如Jackson),而不是在工件中捆绑Jackson jar。
As far as I know it is the first option that holds true, but this doubt came to mind when I was following the AWS Tutorial of thumbnails and it eventually created a jar that had classes for dependencies (like Jackson) rather than bundling Jackson jar in the artifact.
是否有一个示例AWS Lambda zip文件,我可以下载并试用(一个有依赖关系捆绑为.jar文件,而不是.class文件)
Is there a sample AWS Lambda zip file that I can download and try (the one that has dependencies bundled as .jar files and not as .class files)
推荐答案
你应该将依赖关系jar包含在一个 lib
子目录。如果你有一个类 mypackage.LambdaFunctionHandler
,那么zip文件应具有以下基本结构:
You should include the dependency jars in a lib
subdirectory. If you have a class mypackage.LambdaFunctionHandler
, the zip file should have this basic structure:
.
|-- mypackage
| +-- LambdaFunctionHandler.class
+-- lib
|-- myjar1.jar
+-- myjar2.jar
这篇关于构建AWS Lambda jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!