简体   繁体   English

如何从 Jboss EAP 6.4 中部署的所有战争的 manifest.mf 文件中获取实现版本详细信息

[英]How to get implementation version details from manifest.mf file from all the war deployed in Jboss EAP 6.4

we have many war applications deployed in Jboss Eap 6.4 server.The War file is build using Maven and hot deployed in Jboss EAP server.我们在 Jboss Eap 6.4 服务器上部署了许多 war 应用程序。War 文件是使用 Maven 构建的,并热部署在 Jboss EAP 服务器上。 The name of the war file contains only the artifact id and not the implementation version of the application,we have removed the version in the name of the war file due to some other issues in the product.The version related details are present inside the war file in manifest.mf file. war文件名只包含artifact id,不包含应用程序的实现版本,由于产品中的一些其他问题,我们删除了war文件名中的版本。 版本相关的细节在war里面manifest.mf 文件中的文件。

How do we to get the version the war file deployed in the server.我们如何获取服务器中部署的war文件的版本。

Could you please let me know the possible options to get the implementation version details.您能否让我知道获取实现版本详细信息的可能选项。

You could have a piece of java code to do that for you inside the war,which gets executed during first hit of the context-root .您可以在战争中使用一段 Java 代码为您执行此操作,该代码在first hit of the context-root期间执行。 Something like this should do:这样的事情应该做:


public String getVersionNameFromManifest() throws IOException {
    InputStream manifestStream = getClass().getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
    if (manifestStream != null) {
        Manifest manifest = new Manifest(manifestStream);
        Attributes attributes = manifest.getMainAttributes();
        return attributes.getValue("versionName");

    }
    return "Not Found";
}

This should return the exact version of jars in use and in case of any issue it would return a String "Not Found".这应该返回正在使用的 jar 的确切版本,如果出现任何问题,它将返回一个字符串“未找到”。

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

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