项目打包的时候,js文件后缀类似这样的,a.js?v==TIMESTAMP 没有replace成功:
其中pom.xml配置如下:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<!-- the replace should happen before the app is packaged -->
<id>replace-for-compile</id>
<phase>compile</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<!-- replace the token in this file -->
<include>**/target/**/*.jsp</include>
</includes>
<encoding>UTF-8</encoding>
<regex>false</regex>
<!-- the name of the token to replace -->
<token>TIMESTAMP</token>
<!-- replace it with the maven project version -->
<value>${maven.build.timestamp}</value>
</configuration>
</execution>
<execution>
<id>replace-for-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<!-- replace the token in this file -->
<include>**/src/main/resources/**/*.xml</include>
<include>**/src/main/webapp/WEB-INF/*.xml</include>
<include>**/src/main/resources/*.properties</include>
<include>**/src/test/java/com/tf8/util/TestBeanFactory.java</include>
</includes>
<encoding>UTF-8</encoding>
<regex>false</regex>
<!-- the name of the token to replace -->
<token>__artifactId__</token>
<!-- replace it with the maven project version -->
<value>invite</value>
</configuration>
</execution>
</executions>
</plugin>
后来修改成如下,主要是去掉了replace-for-generate

成功。
Maven替换文件版本号
本文介绍了一种使用Maven的replacer插件来更新项目中特定文件内版本号的方法。通过配置pom.xml文件中的插件参数,在构建过程中自动替换指定文件中的占位符,确保版本号的一致性和准确性。
2万+

被折叠的 条评论
为什么被折叠?



