[英]Replace value in my Web.xml with maven
我的Web.xml中有一個值
<display-name> MyApp version @minorversion@- Pré prod </display-name>
我想知道是否可以在編譯或打包時使用maven讀取屬性文件以替換Web.xml中的值。
您可以使用maven-replacer-plugin
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>REPLACE</id>
<goals>
<goal>replace</goal>
</goals>
<phase>{Phase to execute in}</phase>
<configuration>
<file>${Path to file to replace}</file>
<regex>true</regex>
<token>${Regex to match in file}</token>
<value>${New Value to Replace matched}</value>
<regexFlags>
<regexFlag>MULTILINE</regexFlag>
<regexFlag>DOTALL</regexFlag>
</regexFlags>
</configuration>
</execution>
</executions>
</plugin>
添加src \\ main \\ resources \\ conf.properties:
minorversion=1.0.0.0
pom.xml
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <resourceEncoding>${project.build.sourceEncoding}</resourceEncoding> <webResources> <resource> <filtering>true</filtering> <directory>src/main/webapp</directory> <includes> <include>**/web.xml</include> </includes> </resource> </webResources> <filters> <filter>src/main/resources/conf.properties</filter> </filters> </configuration> </plugin>
web.xml
... @minorversion@
要么
${minorversion} ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.