AWS Lambda是否可以访问META-INF/MANIFEST.MF? [英] Aws Lambda access to META-INF/MANIFEST.MF?

查看:74
本文介绍了AWS Lambda是否可以访问META-INF/MANIFEST.MF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯用与组件版本,构建时间等有关的信息来填充我构建的每个jar文件的META-INF/MANIFEST.MF.

I'm in the habit of filling in the META-INF/MANIFEST.MF of every jar file I build with information related to the version of the component, build time, ...

我希望我的lambda记录该信息和/或将其作为其输出的一部分.

I want my lambda to log that information and/or have it as a part of its output.

在大多数情况下,我可以使用类似于以下代码的代码来访问它: {code} GreatestClassNameEver.class.getPackage().getImplementationVersion(){code}

In most cases, I can access this with code similar to: {code}GreatestClassNameEver.class.getPackage().getImplementationVersion(){code}

我用自己的lambda尝试了此操作,但是{code} getImplementationVersion(){code}返回null.

I tried this with my lambda, but {code}getImplementationVersion(){code} returns null.

推荐答案

创建AWS支持票证后,事实证明这是不可能的,因为Lambda是如何提取Jar的.

After creating an AWS support ticket, it turns out that this isn't possible due to how Lambda extracts the Jar.

拆卸jar时,其文件提取如下:

When the jar is disassembled it's files are extracted as follows:

  • /var/task/
  • 中的类文件
  • /var/task/lib中的库
  • /var/task/resources中的
  • 属性和其他配置文件
  • class files in /var/task/
  • libraries in /var/task/lib
  • properties and other config files in /var/task/resources

但在此过程中未提取META-INF目录.

but the META-INF directory is not extracted during this process.

他们给我的解决方法是使用插件将清单复制到Resources目录,并从/var/task/resources/...中读取以获取所需的信息.

The workaround they gave me was to use a plugin to copy the manifest to the Resources directory and read from the /var/task/resources/... to get the information you need.

这篇关于AWS Lambda是否可以访问META-INF/MANIFEST.MF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆