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

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

 更新時(shí)間:2024年12月09日 09:02:09   作者:保持充電  
文章介紹了在SpringBoot項(xiàng)目中,根據(jù)不同的環(huán)境(開(kāi)發(fā)、測(cè)試、生產(chǎn))進(jìn)行JSP文件打包處理的方法,通過(guò)配置`pom.xml`文件中的``標(biāo)簽,可以實(shí)現(xiàn)開(kāi)發(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文件,廢話不多說(shuō)

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

SpringBoot 2.6.1、JDK 1.8

  • dev:開(kāi)發(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)文章

  • SpringBoot項(xiàng)目集成MinIO全過(guò)程

    SpringBoot項(xiàng)目集成MinIO全過(guò)程

    這篇文章主要介紹了SpringBoot項(xiàng)目集成MinIO全過(guò)程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Springboot中依賴注入的三種方式詳解

    Springboot中依賴注入的三種方式詳解

    這篇文章主要介紹了Springboot中依賴注入的三種方式詳解,Setter Injection需要依賴@Autowired注解,使用方式與Field Injection有所不同,Field Injection時(shí)@Autowired是用在成員變量上,需要的朋友可以參考下
    2023-09-09
  • SpringAOP中的通知Advice解析

    SpringAOP中的通知Advice解析

    這篇文章主要介紹了SpringAOP中的通知Advice解析,AOP 中的通知是基于連接點(diǎn)業(yè)務(wù)邏輯的一種增強(qiáng),Spring AOP 可以基于 XML 方式和基于注解方式定義,只是寫法不同,這里只使用注解的方式來(lái)講解通知的詳細(xì)用法,需要的朋友可以參考下
    2023-09-09
  • 如何手寫一個(gè)Spring Boot Starter

    如何手寫一個(gè)Spring Boot Starter

    這篇文章主要介紹了如何手寫一個(gè)Spring Boot Starter,幫助大家更好的理解和學(xué)習(xí)使用Java,感興趣的朋友可以了解下
    2021-03-03
  • 完美解決SpringCloud-OpenFeign使用okhttp替換不生效問(wèn)題

    完美解決SpringCloud-OpenFeign使用okhttp替換不生效問(wèn)題

    這篇文章主要介紹了完美解決SpringCloud-OpenFeign使用okhttp替換不生效問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-02-02
  • Spring實(shí)戰(zhàn)之獲取方法返回值操作示例

    Spring實(shí)戰(zhàn)之獲取方法返回值操作示例

    這篇文章主要介紹了Spring實(shí)戰(zhàn)之獲取方法返回值操作,涉及spring配置文件與方法返回值操作相關(guān)使用技巧,需要的朋友可以參考下
    2019-12-12
  • SpringBoot返回文件讓前端下載的幾種方式

    SpringBoot返回文件讓前端下載的幾種方式

    文章介紹了開(kāi)發(fā)中文件下載的兩種常見(jiàn)解決方案,并詳細(xì)描述了通過(guò)后端進(jìn)行下載的原理和步驟,包括一次性讀取到內(nèi)存和分塊寫入響應(yīng)輸出流兩種方法,此外,還提供了從網(wǎng)絡(luò)上獲取文件和文本并下載的示例,并總結(jié)了InputStream和OutputStream的區(qū)別,感興趣的朋友跟隨小編一起看看吧
    2025-12-12
  • Java實(shí)現(xiàn)五子棋游戲(2.0)

    Java實(shí)現(xiàn)五子棋游戲(2.0)

    這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • 詳解Spring boot使用Redis集群替換mybatis二級(jí)緩存

    詳解Spring boot使用Redis集群替換mybatis二級(jí)緩存

    本篇文章主要介紹了詳解Spring boot使用Redis集群替換mybatis二級(jí)緩存,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Java實(shí)現(xiàn)單例模式的五種方法介紹

    Java實(shí)現(xiàn)單例模式的五種方法介紹

    單例模式確保某個(gè)類只有一個(gè)實(shí)例,而且自行實(shí)例化并向整個(gè)系統(tǒng)提供這個(gè)實(shí)例。在計(jì)算機(jī)系統(tǒng)中,線程池、緩存、日志對(duì)象、對(duì)話框、打印機(jī)、顯卡的驅(qū)動(dòng)程序?qū)ο蟪1辉O(shè)計(jì)成單例
    2023-01-01

最新評(píng)論

东安县| 金堂县| 桃江县| 黔东| 略阳县| 大埔区| 贵德县| 嘉黎县| 宜宾县| 光山县| 玉溪市| 靖安县| 建德市| 长阳| 会泽县| 亳州市| 葫芦岛市| 东山县| 舒兰市| 三河市| 宁强县| 上栗县| 和田县| 崇仁县| 新疆| 犍为县| 珲春市| 樟树市| 沙田区| 抚州市| 仁怀市| 大宁县| 石河子市| 庐江县| 贺兰县| 交城县| 南丰县| 宜兰县| 车致| 朝阳市| 师宗县|