欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot Maven打包如何根據(jù)環(huán)境排除文件

 更新時(shí)間:2024年12月09日 09:02:09   作者:保持充電  
文章介紹了在SpringBoot項(xiàng)目中,根據(jù)不同的環(huán)境(開發(fā)、測(cè)試、生產(chǎn))進(jìn)行JSP文件打包處理的方法,通過配置`pom.xml`文件中的``標(biāo)簽,可以實(shí)現(xiàn)開發(fā)環(huán)境保留`index.jsp`文件,測(cè)試環(huán)境和生產(chǎn)環(huán)境排除該文件

需求背景

最近在項(xiàng)目上有個(gè)需求,要求把生產(chǎn)環(huán)境中的某些文件下掉,測(cè)試環(huán)境要保留,文件不能刪,所以就在打包的時(shí)候做處理,項(xiàng)目中是jsp文件,廢話不多說

項(xiàng)目結(jié)構(gòu)

SpringBoot 2.6.1、JDK 1.8

  • dev:開發(fā)環(huán)境
  • lst:測(cè)試環(huán)境
  • procloud:生產(chǎn)環(huán)境

項(xiàng)目pom.xml文件配置(maven)

<build> 標(biāo)簽

<profiles>標(biāo)簽(多環(huán)境需要)

profiles 下的子標(biāo)簽 profile,每個(gè)子標(biāo)簽對(duì)應(yīng)一個(gè)環(huán)境

測(cè)試環(huán)境打包保留index.jsp

生產(chǎn)環(huán)境打包排除index.jsp

最終pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>iss-manager</artifactId>
    <name>iss-manager</name>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <!-- jasper -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <!--<scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>iss-manager</finalName>
        <resources>
            <resource>
                <directory>src/main/resources/</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yaml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources/</directory>
                <filtering>false</filtering>
                <includes>
                    <include>static/</include>
                    <include>templates/</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.2.RELEASE</version>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>utf-8</encoding>
                    <useDefaultDelimiters>true</useDefaultDelimiters>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- 測(cè)試環(huán)境 -->
            <id>lst</id>
            <properties>
                <profileActive>lst</profileActive>
            </properties>

            <build>
                <!-- 資源文件管理-->
                <resources>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*.*</include>
                        </includes>
                        <filtering>true</filtering>
                        <targetPath>META-INF/resources</targetPath>
                        <excludes>
                            <exclude>**/*.woff</exclude>
                            <exclude>**/*.woff2</exclude>
                            <exclude>**/*.ttf</exclude>
                            <exclude>**/*.eot</exclude>
                            <exclude>**/*.svg</exclude>
                            <exclude>**/*.docx</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*.*</include>
                            <include>**/*.woff</include>
                            <include>**/*.woff2</include>
                            <include>**/*.ttf</include>
                            <include>**/*.eot</include>
                            <include>**/*.svg</include>
                        </includes>
                        <filtering>false</filtering>
                        <targetPath>META-INF/resources</targetPath>
                    </resource>
                </resources>
            </build>
        </profile>

        <profile>
            <!-- 生產(chǎn)環(huán)境-->
            <id>procloud</id>
            <properties>
                <profileActive>procloud</profileActive>
            </properties>
            <build>
                <!-- 資源文件管理-->
                <resources>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*.*</include>
                        </includes>
                        <filtering>true</filtering>
                        <targetPath>META-INF/resources</targetPath>
                        <excludes>
                            <exclude>**/*.woff</exclude>
                            <exclude>**/*.woff2</exclude>
                            <exclude>**/*.ttf</exclude>
                            <exclude>**/*.eot</exclude>
                            <exclude>**/*.svg</exclude>
                            <exclude>**/*.docx</exclude>
                            <!-- 生產(chǎn)環(huán)境打包排除index.jsp文件 -->
                            <exclude>**/index.jsp</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*.*</include>
                            <include>**/*.woff</include>
                            <include>**/*.woff2</include>
                            <include>**/*.ttf</include>
                            <include>**/*.eot</include>
                            <include>**/*.svg</include>
                        </includes>
                        <filtering>false</filtering>
                        <targetPath>META-INF/resources</targetPath>
                        <excludes>
                            <!-- 生產(chǎn)環(huán)境打包排除index.jsp文件 -->
                            <exclude>**/index.jsp</exclude>
                        </excludes>
                    </resource>
                </resources>
            </build>
        </profile>
    </profiles>
</project>

總結(jié)

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

相關(guān)文章

  • spring boot結(jié)合Redis實(shí)現(xiàn)工具類的方法示例

    spring boot結(jié)合Redis實(shí)現(xiàn)工具類的方法示例

    這篇文章主要介紹了spring boot結(jié)合Redis實(shí)現(xiàn)工具類的方法示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-11-11
  • java中Map和List初始化的N種方法總結(jié)

    java中Map和List初始化的N種方法總結(jié)

    這篇文章主要介紹了java中Map和List初始化的N種方法總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • Java中關(guān)于控制臺(tái)讀取數(shù)字或字符串的方法

    Java中關(guān)于控制臺(tái)讀取數(shù)字或字符串的方法

    下面小編就為大家?guī)硪黄狫ava中關(guān)于控制臺(tái)讀取數(shù)字或字符串的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-10-10
  • 微信小程序后端Java接口開發(fā)的詳細(xì)步驟

    微信小程序后端Java接口開發(fā)的詳細(xì)步驟

    現(xiàn)在微信小程序越來越火了,相信不少人都通過各種途徑學(xué)習(xí)過微信小程序或者嘗試開發(fā),本文就介紹了微信小程序后端Java接口開發(fā)的詳細(xì)步驟,感興趣的同學(xué)可以學(xué)習(xí)一下
    2021-11-11
  • mybatis中方法返回泛型與resultType不一致的解決

    mybatis中方法返回泛型與resultType不一致的解決

    這篇文章主要介紹了mybatis中方法返回泛型與resultType不一致的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • MybatisPlus使用@TableLogic實(shí)現(xiàn)邏輯刪除過程

    MybatisPlus使用@TableLogic實(shí)現(xiàn)邏輯刪除過程

    這篇文章主要介紹了MybatisPlus使用@TableLogic實(shí)現(xiàn)邏輯刪除過程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)

    java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • SpringBoot集成redis實(shí)現(xiàn)共享存儲(chǔ)session

    SpringBoot集成redis實(shí)現(xiàn)共享存儲(chǔ)session

    這篇文章主要介紹了SpringBoot集成redis實(shí)現(xiàn)共享存儲(chǔ)session的流程步驟,文中通過代碼示例介紹的非常詳細(xì),并總結(jié)了一些常見的錯(cuò)誤及解決方法,需要的朋友可以參考下
    2024-03-03
  • Java啟動(dòng)Tomcat的實(shí)現(xiàn)步驟

    Java啟動(dòng)Tomcat的實(shí)現(xiàn)步驟

    本文主要介紹了Java啟動(dòng)Tomcat的實(shí)現(xiàn)步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-05-05
  • formfile文件上傳使用示例

    formfile文件上傳使用示例

    這篇文章主要介紹了formfile文件上傳使用示例,代碼已加注釋,需要的朋友可以參考下
    2014-03-03

最新評(píng)論