我正在尝试使用maven-replacer- pom.xml查找并替换html标记。使用当前的配置,我得到了一个错误,“缺少结束标签地址”,这意味着pom没有转义开放标签<和关闭标签>。
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<id>replace-script-reset-path-variable</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<include>${basedir}/books/*.xml</include>
</includes>
<replacements>
<replacement>
<token>/<(address)>/</token>
<value>/<(address)>//abc.com</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>目标是用<address>abc.com/替换源文件中具有html标记<address>的所有行
下面是我的源文件示例:
<address>books/category/ebooks1/index.html</address>
<address>books/category/ebooks2/index.html</address>
<address>books/category/ebooks3/index.html</address>
<address>books/category/ebooks4/index.html</address>
<address>books/category/ebooks5/index.html</address>应用正则表达式后,预期的源文件应为:
<address>abc.com/books/category/ebooks1/index.html</address>
<address>abc.com/books/category/ebooks2/index.html</address>
<address>abc.com/books/category/ebooks3/index.html</address>
<address>abc.com/books/category/ebooks4/index.html</address>
<address>abc.com/books/category/ebooks5/index.html</address>发布于 2013-09-13 22:29:41
您需要将实际POM文件中的<转义为<,对于<也是如此,
发布于 2015-02-09 19:44:58
我建议您使用令牌和值文件。在它们中,您可以简单地编写以下代码:
<address>和
<address>abc.com然后您只需输入文件的正确路径。例如:
<tokenFile>resources/common/address-token.txt</tokenFile>
<valueFile>resources/common/address-value.txt</valueFile>有关更多详细信息,请访问Replacer usage guide
https://stackoverflow.com/questions/18788657
复制相似问题