简体   繁体   English

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

[英]Determine deployed web application version

I am developing web application on Java platform using JSF, Maven build, SVN. 我正在使用JSF,Maven build,SVN在Java平台上开发Web应用程序。

I have already included the application version number, revision, date extra on the jar/war manifest using maven plugin. 我已经使用maven插件在jar / war清单中包括了应用程序的版本号,修订版和其他日期。

How can I find the version number of the deployed application from the browser using page view source (if I want hide this from the end user) ? 如何使用页面视图源从浏览器中找到已部署应用程序的版本号(如果我想向最终用户隐藏此版本号)?

stackoverflow.com display the version details at the footer eg rev 2013.10.20.1076. stackoverflow.com在页脚处显示版本详细信息,例如rev 2013.10.20.1076。

Another possible alternative is as follows: 另一种可能的替代方法如下:

Use versions:set -DnewVersion={{YOUR_VERSION_NUMBER}} to set the version. 使用versions:set -DnewVersion={{YOUR_VERSION_NUMBER}}设置版本。

Then in the maven-war-plugin: 然后在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>

Finally, you can use jcabi-manifests to do further processing. 最后,您可以使用jcabi-manifests进行进一步处理。

You can use this maven plugin : 您可以使用以下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>

Then you can insert this in the base xhtml template for your application (well... in something that ends up in all your pages if you want it on all pages) : 然后,您可以将其插入到应用程序的基本xhtml模板中(好吧,如果希望在所有页面上都可以在所有页面中找到):

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

Note : this will work on a maven-built war. 注意:这将在行家建立的战争中起作用。 If you don't use maven while testing your webapp with Eclipse for instance, you'll still have ${pom.version} not replaced. 例如,如果在使用Eclipse测试${pom.version}应用程序时不使用maven,则仍然会替换${pom.version}

You can create some text static file with content: 您可以创建一些包含内容的文本静态文件:

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

and put it to src\\main\\webapp\\about\\info.txt , use com.google.code.maven-svn-revision-number-plugin to provide values for above variables: 并将其放入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>

The file will be available under http://your-domain.com/resources/about/info.txt 该文件将在http://your-domain.com/resources/about/info.txt下提供

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

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