[TOC]
The war way
- Add properties below
<properties> <! -- maven. Build. The timestamp default timestamp format - > < maven. Build. The timestamp. The format > yyyyMMddHHmmss < / maven. Build. The timestamp. The format > </properties>Copy the code
- pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<useCache>true</useCache>
</configuration>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<! -- Replace before packing -->
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<! -- Automatically identify the project target folder -->
<basedir>${project.build.directory}</basedir>
<! -- Replace the file directory rule -->
<includes>
<include>${project.build.finalName}/index.html</include>
<! -- <include>${project.build.finalName}/WEB-INF/**/*.html</include>-->
</includes>
<replacements>
<! Change the rule to append? To CSS /js files V = timestamp, backslash indicates character escape -->
<replacement>
<token>\.css\"</token>
<value>.css? v=${project.version}-${maven.build.timestamp}\"</value>
</replacement>
<replacement>
<token>\.css\'</token>
<value>.css? v=${project.version}-${maven.build.timestamp}\'</value>
</replacement>
<replacement>
<token>\.js\"</token>
<value>.js? v=${project.version}-${maven.build.timestamp}\"</value>
</replacement>
<replacement>
<token>\.js\'</token>
<value>.js? v=${project.version}-${maven.build.timestamp}\'</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
</build>
Copy the code
Springboot jar way
- Add properties below
<properties> <! -- maven. Build. The timestamp default timestamp format - > < maven. Build. The timestamp. The format > yyyyMMddHHmmss < / maven. Build. The timestamp. The format > </properties>Copy the code
- Add plugins to projects that contain front-end pages
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<! -- Replace before packing -->
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<! -- Automatically identify the project target folder -->
<basedir>${project.build.directory}</basedir>
<! -- Notice, must not write wrong -->
<includes>
<include>classes/static/index.html</include>
</includes>
<replacements>
<! Change the rule to append? To CSS /js files V = timestamp, backslash indicates character escape -->
<replacement>
<token>\.css\"</token>
<value>.css? v=${project.version}-${maven.build.timestamp}\"</value>
</replacement>
<replacement>
<token>\.css\'</token>
<value>.css? v=${project.version}-${maven.build.timestamp}\'</value>
</replacement>
<replacement>
<token>\.js\"</token>
<value>.js? v=${project.version}-${maven.build.timestamp}\"</value>
</replacement>
<replacement>
<token>\.js\'</token>
<value>.js? v=${project.version}-${maven.build.timestamp}\'</value>
</replacement>
</replacements>
</configuration>
</plugin>
</build>
Copy the code