简体   繁体   中英

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. 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.

How do we to get the version the war file deployed in the server.

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 . 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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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