繁体   English   中英

确定已部署的Web应用程序版本

[英]Determine deployed web application version

我正在使用JSF,Maven build,SVN在Java平台上开发Web应用程序。

我已经使用maven插件在jar / war清单中包括了应用程序的版本号,修订版和其他日期。

如何使用页面视图源从浏览器中找到已部署应用程序的版本号(如果我想向最终用户隐藏此版本号)?

stackoverflow.com在页脚处显示版本详细信息,例如rev 2013.10.20.1076。

另一种可能的替代方法如下:

使用versions:set -DnewVersion={{YOUR_VERSION_NUMBER}}设置版本。

然后在maven-war-plugin中:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <archive>
                    <manifestEntries>
                        <your-version>${project.version}</your-version>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

最后,您可以使用jcabi-manifests进行进一步处理。

您可以使用以下Maven插件:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <!-- Impossible de filtrer les ressources web de l'application avec le plugin v2.0.2 Nécessaire pour 'versioner' les .css, .js Maven 2.x WAR Plugin MWAR-134 -->
            <version>2.1.1</version>
            <configuration>
                <!-- Maven 2.x WAR Plugin MWAR-187 regression running war packaging with maven 2.1 Stephane Nicoll added a comment - 07/Jul/09 3:28 AM One way to quickly work around this issue is to deactivate the cache. -->
                <useCache>false</useCache>
                <webResources>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <!-- Filtering activates replacement of ${pom.version} in *.xhtml... -->
                        <filtering>true</filtering>
                        <!-- I've chosen to exlude manually these resources from the filtering -->
                        <excludes>
                            <exclude>**/*.xml</exclude>
                        </excludes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

然后,您可以将其插入到应用程序的基本xhtml模板中(好吧,如果希望在所有页面上都可以在所有页面中找到):

<span style="display:hidden">${pom.version}"</span>

注意:这将在行家建立的战争中起作用。 例如,如果在使用Eclipse测试${pom.version}应用程序时不使用maven,则仍然会替换${pom.version}

您可以创建一些包含内容的文本静态文件:

version: ${pom.version}
build time: ${build.time}
svn revision: ${svn.revision}
svn path: ${svn.path}
committed date: ${svn.committedDate}

并将其放入src \\ main \\ webapp \\ about \\ info.txt ,使用com.google.code.maven-svn-revision-number-plugin为上述变量提供值:

<build>
        <plugins>
            .......
            <plugin>
                <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
                <artifactId>svn-revision-number-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <entries>
                        <entry>
                            <prefix>svn</prefix>
                        </entry>
                    </entries>
                </configuration>
            </plugin>
              .....
     </plugins>
   .........
</build>

该文件将在http://your-domain.com/resources/about/info.txt下提供

暂无
暂无

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

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