【问题标题】:Replacing tokens in web.xml using Google Maven replacer for WAR packaging使用 Google Maven 替换器替换 web.xml 中的令牌以进行 WAR 打包
【发布时间】:2016-12-29 14:50:15
【问题描述】:

我的web.xml${project.root}\src\main\webapp\WEB-INF 之下。

我想用com.google.code.maven-replacer-plugin替换其中的一些标记当它被打包在WAR中而不是在源目录中时

我试过了:

<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.2</version>
  <executions>
    <execution>
      <phase>prepare-package</phase>
      <goals>
        <goal>replace</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <file>src/main/webapp/WEB-INF/web.xml</file>
    <replacements>
      <replacement>
        <token>@@sec.level@@</token>
        <value>local</value>
      </replacement>
    </replacements>
  </configuration>
</plugin>

但我得到了

[ERROR] File '.\src\main\webapp\WEB-INF\web.xml' does not exist

由于该文件不是在target 文件结构下复制的,而是直接从源中获取到WAR 中(或者我认为),我如何在上面的configuration-&gt;file 参数中引用它的路径,以便replacer 找到它并替换令牌?

【问题讨论】:

    标签: maven maven-replacer-plugin


    【解决方案1】:

    尝试使用如下路径

    ${project.basedir}/src/main/webapp/WEB-INF/web.xml
    

    更多关于不同变量的信息maven properties

    【讨论】:

    • 但是,这会更改源中的文件,我想保持源不变(保留令牌)并且只在构建和 WAR 文件中更改它
    • 您是否尝试过使用 ${project.build.directory},但您需要提供适当的阶段(因为必须在创建 war 文件之前完成)
    猜你喜欢
    • 1970-01-01
    • 2012-01-19
    • 2014-06-23
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 1970-01-01
    • 2013-02-27
    • 2019-02-25
    相关资源
    最近更新 更多