在AngularJS中显示POM版本号 [英] Displaying POM version number in AngularJS

查看:195
本文介绍了在AngularJS中显示POM版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Angular App中显示POM文件中包含的版本号的最有效方法是什么?

What's the most efficient way of displaying the version number contained in a POM file in my Angular App?

我有一个在Tomcat上运行的REST应用程序.

I have a REST application running on Tomcat.

我想有两种选择

  1. 拥有一个仅提供应用程序版本号的REST服务
  2. 在mvn构建过程中创建一个文本文件,然后将其复制到网络应用中,然后从前端读取该文件

以前有人遇到过吗?

推荐答案

典型的方法是在Web应用程序的某些文件中为该版本添加占位符,并在编译时替换该占位符:

The typical way of doing that is by adding a placeholder for the version in some file of your web-application and replacing that placeholder at compile time:

  1. 在您选择的src/main/webapp下的文件中添加占位符${project.version}.
  2. 像这样配置maven-war-plugin:

  1. Add the placeholder ${project.version} in a file of your choice under src/main/webapp.
  2. Configure the maven-war-plugin like this:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
            </resource>
        </webResources>
    </configuration>
</plugin>

此插件将在构建时将占位符${project.version}替换为当前的Maven版本.

This plugin will replace the placeholder ${project.version} with the current Maven version at build time.

您的应用程序其余部分现在可以访问Maven版本,就好像它是一个简单的硬编码字符串一样.

The rest of your application can now access the Maven version as if it were a simple hard-coded String.

这篇关于在AngularJS中显示POM版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆