Maven project file configuration packaging function and static resource file version number function
For example:
Reference js file in html file
<script src="js/jquery-2.0."></script>
After packaging, it will become
<script src="js/jquery-2.0.?v=2021-07-09T09:29:42Z"></script>
Added in the tag
<build> <plugins> <!--Configure Packaging start--> <plugin> <groupId></groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!--Configure Packaging end--> <!--Configure the page file with its own version number start--> <plugin> <groupId>-replacer-plugin</groupId> <artifactId>replacer</artifactId> <version>1.5.3</version> <executions> <execution> <phase>prepare-package</phase> <goals> <goal>replace</goal> </goals> </execution> </executions> <configuration> <includes> <include>${basedir}/target/classes/templates/**/*.html</include> </includes> <replacements> <replacement> <token>\.js\"</token> <value>.js?v=${}\"</value> </replacement> <replacement> <token>\.js\'</token> <value>.js?v=${}\'</value> </replacement> <replacement> <token>\.css\"</token> <value>.css?v=${}\"</value> </replacement> <replacement> <token>\.css\'</token> <value>.css?v=${}\'</value> </replacement> </replacements> </configuration> </plugin> <!--Configure the page file with its own version number end--> </plugins> </build>
Maven contains resource static file when packaged
<build> <!-- mavenIncludes static resource files when packaged --> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.yaml</include> <include>META-INF/**</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.