【问题标题】:Vaadin Maven Build Properties in HTML fileHTML 文件中的 Vaadin Maven 构建属性
【发布时间】:2018-09-04 22:07:45
【问题描述】:

我正在使用带有自定义布局的 Vaadin 8,其中包括 About.html 文件。该文件包含 buildId 和 Version 信息,如下所示。

aboutview.html

<p>
    Version: ${buildVersion}<br /> Build id: ${buildId}<br />
</p>

myui/pom.xml 文件

<properties>
    <maven.build.timestamp.format>yyyyMMdd HHmm</maven.build.timestamp.format>
    <buildTimestamp>${maven.build.timestamp}</buildTimestamp>
    <buildVersion>2.0.0</buildVersion>
    <buildId>${buildTimestamp}</buildId>
</properties>
org.apache.maven.plugins maven-war-plugin true WEB-INF/classes/VAADIN/gwt-unitCache/, WEB-INF/classes/VAADIN/widgetsets/WEB-INF/

                <resources>
                    <resource>
                        <directory>src/main/webapp/VAADIN/themes/abstheme/layouts</directory>
                        <includes>
                            <include>aboutview.html</include>
                        </includes>
                        <filtering>true</filtering>
                    </resource>
                </resources>

            </configuration>
        </plugin></plugins></build>

如何确保在 Tomcat 服务器中部署后,aboutview.html 中的属性值可用?

TIA

【问题讨论】:

  • 不确定你的意思。 Filtering 资源将在构建期间替换占位符/变量,因此您实际上将在运行时将版本嵌入到 aboutview.html 页面中。我在这里错过了什么?
  • 过滤不会在构建后替换变量/占位符。 aboutview.html 页面仍然包含 $buildId 和 $version 占位符而不是值。我的问题是用不工作的值替换占位符
  • 哪个文件仍然有变量,是你(重新)源中的那个,还是目标目录中的那个(或由此产生的战争)?

标签: html maven build vaadin vaadin8


【解决方案1】:

根据此文档https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html,您可以在项目的根目录下创建一个“resource2”文件夹并将文件放在那里。

然后,在您的 pom.xml 中,您将添加以下配置

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <webResources>
                    <resource>
                        <directory>resource2</directory>
                        <targetPath>VAADIN/themes/abstheme/layout</targetPath>
                        <filtering>true</filtering>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

【讨论】:

  • 感谢 Tulio, 标签解决了这个问题。
猜你喜欢
  • 2012-08-18
  • 2016-11-21
  • 1970-01-01
  • 1970-01-01
  • 2021-09-29
  • 2016-03-24
  • 2016-09-20
  • 1970-01-01
  • 2019-02-24
相关资源
最近更新 更多