在 java web 应用程序中显示/使用修订号的最佳方式是什么?
我们只使用 ant 来构建我们的 .war 存档,没有构建服务器之类的。我希望有某种 if $ref 可以写入资源文件中,但这仅在提交相关文件时更新。我在全球范围内都需要它。
你会推荐什么?更新某些文件的提交后触发器?
自定义 Ant 脚本?有没有一种更简单的方法来做到这一点?
或者最好有我自己的独立于 svn 的版本号。
编辑:很好的建议!非常感谢您的回答!
我们使用以下 ant 任务将 svn 版本包含在 jar 的属性中,以及正在使用的其他包的版本
<target name="package" depends="compile" description="Package up the project as a jar">
<!-- Create the subversion version string -->
<exec executable="svnversion" failifexecutionfails="no" outputproperty="version">
<arg value="."/>
<arg value="-n"/>
</exec>
<!-- Create the time stamp -->
<tstamp>
<format property="timeAndDate" pattern="HH:mm d-MMMM-yyyy"/>
</tstamp>
<jar destfile="simfraserv.jar">
<manifest>
<attribute name="Built-By" value="${user.name} on ${time.date}" />
<attribute name="Implementation-Version" value="${svn.version}" />
<attribute name="Implementation-Java" value="${java.vendor} ${java.version}" />
<attribute name="Implementation-Build-OS" value="${os.name} ${os.arch} ${os.version}" />
<attribute name="JVM-Version" value="${common.sourcelevel}+" />
</manifest>
<fileset dir="bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="src">
<include name="**"/>
</fileset>
</jar>
</target>
然后你可以像这样在你的网络应用程序中访问它
String version = this.getClass().getPackage().getImplementationVersion();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)