简体   繁体   English

WAR,manifest.mf和版本

[英]WAR, manifest.mf and version

I have a WAR file, and inside a /META-INF/MANIFEST.MF containing my product version info: 我有一个WAR文件,并且在/META-INF/MANIFEST.MF中包含我的产品版本信息:

Implementation-Version: 1.0.0.0

At my index.jsp I have this code to print the version: 在我的index.jsp中,我有以下代码来打印版本:

<%  
String version = com.my.Utils.class.getPackage().getImplementationVersion();
out.print("Version: " + version);
%>

This code always return: 此代码始终返回:

Version: 

This solution is based on this article . 此解决方案基于本文

What I need to do read my version information from war manifest file? 我需要从战争清单文件中读取版本信息吗?

That article you link specifically mentions the second case, where you're deploying a classic web application: 您链接的那篇文章专门提到了第二种情况,即您在其中部署经典Web应用程序:

<%
//Get version of application
java.util.Properties prop = new java.util.Properties();
prop.load(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF"));
String applVersion = prop.getProperty("Implementation-Version");  
%>
<h2 class="x-panel-header"><%=applVersion%></h2>

The method is different depending on how your application is deployed. 该方法因应用程序的部署方式而异。

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

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