0

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

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

我试过了:

<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->file参数中引用它的路径,以便替换器找到它并替换标记?

4

1 回答 1

1

尝试使用如下路径

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

有关不同变量Maven 属性的更多信息

于 2016-08-23T01:05:53.993 回答