在AngularJS中显示POM版本号 [英] Displaying POM version number in AngularJS
问题描述
在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.
我想有两种选择
- 拥有一个仅提供应用程序版本号的REST服务
- 在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:
- 在您选择的
src/main/webapp
下的文件中添加占位符${project.version}
. -
像这样配置
maven-war-plugin
:
- Add the placeholder
${project.version}
in a file of your choice undersrc/main/webapp
. 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屋!