【问题标题】:How to expand Maven properties in all files within src/main/webapp?如何在 src/main/webapp 中的所有文件中扩展 Maven 属性?
【发布时间】:2014-10-27 14:50:12
【问题描述】:

我想在src/main/webapp/META-INF/context.xml 中包含一些 Maven 属性(*)。

(*) 例如${data-source-name}${data-source-factory}${jdbc-connection-url} 等等——但用已故伟大的 Leslie Nielsen 的话来说,现在这并不重要。

认为这可能可以使用以下maven-resource-plugin 配置来实现:

<build>
  <resources>
    <resource>
      <directory>src/main/webapp</directory>
      <includes>
        <include>**/*</include>
      </includes>
      <filtering>true</filtering>
    </resource>
  </resources>
</build>

但这会导致 WAR 文件中有两个版本的 context.xml:

\META-INF\context.xml                 <=== Properties *not* expanded
\WEB-INF\classes\META-INF\context.xml <=== Properties expanded

我哪里出错了?

【问题讨论】:

    标签: maven jakarta-ee war context.xml maven-resources-plugin


    【解决方案1】:

    经过一番谷歌搜索后,我发现了如何使用 maven-war-plugin 而不是 maven-resources-plugin:

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <configuration>
            <webResources>
              <resource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
              </resource>
            </webResources>
          </configuration>
        </plugin>
      </plugins>
    </build>
    

    【讨论】:

      猜你喜欢
      • 2014-03-31
      • 2013-10-30
      • 2020-11-01
      • 2013-10-21
      • 2011-10-02
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多