我正在关注this article,“读取版本”部分,我想读取版本并在输出文件中添加一列,代码是这样的:
ExternalContext application = FacesContext.getcurrentInstance().getExternalContext();
InputStream inputStream = application.getResourceAsStream("/Meta-INF/MANIFEST.MF");
Manifest manifest = new Manifest(inputStream);
Attributes attributes = manifest.getMainAttributes();
String version = attributes.getvalue("Implementation-Version");
我对Java还是很陌生,不确定应该将这段代码放在哪里。
我试图创建一个函数,但是'ExternalContext','FacesContext'和'getResourceAsStream'以红色显示,有人可以帮忙吗?非常感谢。