最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用maven項(xiàng)目pom.xml文件配置打包功能和靜態(tài)資源文件自帶版本號功能

 更新時(shí)間:2024年09月29日 10:01:36   作者:閑走天涯  
在Maven項(xiàng)目中,通過pom.xml文件配置打包功能,可以控制構(gòu)建過程,生成可部署的包,同時(shí),為了緩存控制與版本更新,可以在打包時(shí)給靜態(tài)資源文件如JS、CSS添加版本號,這通常通過插件如maven-resources-plugin實(shí)現(xiàn)

maven項(xiàng)目pom.xml文件配置打包功能和靜態(tài)資源文件自帶版本號功能

例如:

html文件中引用js文件

<script src="js/jquery-2.0.2.min.js"></script>

打包編譯后會變成

<script src="js/jquery-2.0.2.min.js?v=2021-07-09T09:29:42Z"></script>

pom.xml標(biāo)簽內(nèi)增加

<build>
        <plugins>
        	<!--配置打包 start-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!--配置打包 end-->
            <!--配置頁面文件自帶版本號 start-->
            <plugin>
                <groupId>com.google.code.maven-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=${maven.build.timestamp}\"</value>
                        </replacement>
                        <replacement>
                            <token>\.js\'</token>
                            <value>.js?v=${maven.build.timestamp}\'</value>
                        </replacement>
                        <replacement>
                            <token>\.css\"</token>
                            <value>.css?v=${maven.build.timestamp}\"</value>
                        </replacement>
                        <replacement>
                            <token>\.css\'</token>
                            <value>.css?v=${maven.build.timestamp}\'</value>
                        </replacement>
                    </replacements>

                </configuration>
            </plugin>
            <!--配置頁面文件自帶版本號 end-->
        </plugins>
    </build>

maven打包時(shí)包含resource靜態(tài)文件

<build>
        <!-- maven打包時(shí)包含靜態(tài)資源文件 -->
        <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>

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

彭泽县| 阿拉善右旗| 南川市| 安陆市| 丰镇市| 盈江县| 龙州县| 于田县| 阿拉善左旗| 白玉县| 镇巴县| 凉山| 新疆| 寿宁县| 巫溪县| 且末县| 军事| 河曲县| 白山市| 东阿县| 西峡县| 鄄城县| 呼图壁县| 馆陶县| 博乐市| 同江市| 克什克腾旗| 中江县| 龙游县| 巴马| 石泉县| 平武县| 衡水市| 永胜县| 桂东县| 通化市| 恩施市| 钟山县| 柳林县| 上高县| 台北县|