maven pom 動態設置jar包版本


1:“maven父節點”或“當前pom文件加上”以下profiles。(project節點下)

 

    <profiles>
        <profile>
            <id>dev</id><!--開發環境(默認)-->
            <activation>
                <!--默認環境-->
                <activeByDefault>true</activeByDefault>
            </activation>

            <properties>
                <testVerSion>xxxxxDev</testVerSion><!--動態參數標簽-->
                <vvv>xxxxxxxxx</vvv>
            </properties>

        </profile>

        <profile>
        
<id>test</id><!--測試環境--> <properties> <testVerSion>xxxxxTest</testVerSion><!--動態參數標簽--> <vvv>vvv</vvv> </properties> </profile> </profiles>

 

2:pom文件引入jar包(必須要有“默認環境”)

 

<dependency>
<groupId>com.zxy.product</groupId>
<artifactId>system-api</artifactId>
<version>${testVerSion}</version> <!--動態參數讀取-->
</dependency>

3:打包傳遞環境值(測試環境 )
mvn clean package -P test                       這里test傳入后,會自動匹配到 <id>test</id> 的配置

 

 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM