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

基于maven的springboot的"過時"用法解析

 更新時間:2023年09月18日 08:37:37   作者:codecraft  
這篇文章主要為大家介紹了基于maven的springboot"過時"用法示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

接觸過許多工程,發(fā)現(xiàn)有一些基于maven的springboot工程還是使用maven的profile,有些"過時"了,下面簡單介紹一下。

示例1

pom.xml
<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
            </properties>
        </profile>
        <profile>
            <id>staging</id>
            <properties>
                <profiles.active>staging</profiles.active>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profiles.active>prod</profiles.active>
            </properties>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <configuration>
                    <target>1.8</target>
                </configuration>
                <executions>
                    <execution>
                        <id>copy-service-properties</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <copy todir="target/classes/config" overwrite="true">
                                    <fileset dir="${basedir}/src/main/resources/deploy/${profiles.active}">
                                        <include name="*.yml"/>
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
src/main/resources
├── config
│?? ├── application.yml
│?? └── bootstrap.yml
├── deploy
│?? ├── Dockerfile
│?? ├── dev
│?? │?? ├── application.yml
│?? │?? └── bootstrap.yml
│?? ├── prod
│?? │?? ├── application.yml
│?? │?? └── bootstrap.yml
│?? ├── staging
│?? │?? ├── application.yml
│?? │?? └── bootstrap.yml
│?? └── test
│??     ├── application.yml
│??     └── bootstrap.yml

 這種方法呢,感覺是多此一舉,用application-{profile}.yml不香嗎,感覺是沒有用上springboot之前的maven工程的用法

示例2

pom.xml
<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <app.active>dev</app.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <app.active>test</app.active>
            </properties>
        </profile>
        <profile>
            <id>staging</id>
            <properties>
                <app.active>staging</app.active>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <app.active>prod</app.active>
            </properties>
        </profile>
    </profiles>
application.yml
spring:
  profiles:
    active: @app.active@

 這種用法呢,src/main/resources下面只有一個application.yml,把profile的差異放到了maven的profile中,在application.yml引用maven的profile變量,有點"少見多怪",直接application-{profile}.yml用不香嗎。

小結(jié)

springboot工程已經(jīng)提供了profile的特性了,其實大部分場景可以替換掉maven的profile,沒必要在使用maven的profile了,不然總感覺顯得有點古老和過時。

以上就是基于maven的springboot的"過時"用法的詳細內(nèi)容,更多關(guān)于maven的springboot的"過時"用法的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Java編寫日志手機號脫敏工具類

    Java編寫日志手機號脫敏工具類

    在開發(fā)過程中,很容易將用戶敏感信息,例如手機號碼、身份證等,打印在日志平臺,本文將利用Java編寫一個日志手機號脫敏工具類,感興趣的可以了解下
    2024-12-12
  • Java使用ProcessBuilder?API優(yōu)化流程

    Java使用ProcessBuilder?API優(yōu)化流程

    Java?的?Process?API?為開發(fā)者提供了執(zhí)行操作系統(tǒng)命令的強大功能,這篇文章將詳細介紹如何使用?ProcessBuilder?API?來方便的操作系統(tǒng)命令,需要的可以收藏一下
    2023-06-06
  • Lombok在idea中的使用教程

    Lombok在idea中的使用教程

    Lombok是一個可以通過簡單的注解形式,來幫助我們簡化消除一些必須有但顯得很臃腫(如果getter、setter方法)的Java代碼的工具,通過使用對應(yīng)的注解,可以在編譯源碼的時候生成對應(yīng)的方法,這篇文章主要介紹了Lombok在idea中的使用,需要的朋友可以參考下
    2023-03-03
  • Spring?框架的?MethodInterceptor?簡介及示例代碼

    Spring?框架的?MethodInterceptor?簡介及示例代碼

    MethodInterceptor接口定義了一個方法Object?intercept(Object?obj,?Method?method,?Object[]?args,?MethodProxy?proxy)?,該方法在代理對象的方法被調(diào)用時被觸發(fā),這篇文章主要介紹了Spring?框架的?MethodInterceptor?簡介及示例代碼,需要的朋友可以參考下
    2023-09-09
  • Spring使用RestTemplate模擬form提交示例

    Spring使用RestTemplate模擬form提交示例

    本篇文章主要介紹了Spring使用RestTemplate模擬form提交示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • JavaFX程序初次運行創(chuàng)建數(shù)據(jù)庫并執(zhí)行建表SQL詳解

    JavaFX程序初次運行創(chuàng)建數(shù)據(jù)庫并執(zhí)行建表SQL詳解

    這篇文章主要介紹了JavaFX程序初次運行創(chuàng)建數(shù)據(jù)庫并執(zhí)行建表SQL詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-08-08
  • 淺析java中的取整(/)和求余(%)

    淺析java中的取整(/)和求余(%)

    這篇文章主要介紹了淺析java中的取整(/)和求余(%),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-08-08
  • 在Java開發(fā)中無法繞開的SpringBoot框架詳解

    在Java開發(fā)中無法繞開的SpringBoot框架詳解

    SpringBoot是一個基于Spring框架的快速開發(fā)框架,它的出現(xiàn)極大地簡化了Spring應(yīng)用的開發(fā)流程,SpringBoot是一個快速開發(fā)的框架,它提供了一種快速構(gòu)建應(yīng)用程序的方式,本文給大家介紹在Java開發(fā)中無法繞開的框架:SpringBoot,感興趣的朋友一起看看吧
    2023-09-09
  • 詳解JAVA設(shè)計模式之適配器模式

    詳解JAVA設(shè)計模式之適配器模式

    這篇文章主要介紹了JAVA設(shè)計模式之適配器模式的的相關(guān)資料,文中示例代碼非常詳細,供大家參考和學習,感興趣的朋友可以了解
    2020-06-06
  • 使用IDEA創(chuàng)建maven父子工程項目 (圖文)

    使用IDEA創(chuàng)建maven父子工程項目 (圖文)

    本文主要介紹了使用IDEA創(chuàng)建maven父子工程項目,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-04-04

最新評論