<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    itVincent Blog - Java Working Fun!

    技術引領時代!
    posts - 117, comments - 181, trackbacks - 0, articles - 12

    Maven Dependency Scope

    Posted on 2009-12-21 13:58 itVincent 閱讀(1247) 評論(0)  編輯  收藏 所屬分類: maven

     

    Dependency scope 是用來限制Dependency的作用范圍的, 影響maven項目在各個生命周期時導入的package的狀態。

    自從2.0.9后,新增了1種,現在有了6種scope:

    • compile
      默認的scope,表示 dependency 都可以在生命周期中使用。而且,這些dependencies 會傳遞到依賴的項目中。
    • provided
      跟compile相似,但是表明了dependency 由JDK或者容器提供,例如Servlet AP和一些Java EE APIs。這個scope 只能作用在編譯和測試時,同時沒有傳遞性。        
    • runtime
      表示dependency不作用在編譯時,但會作用在運行和測試時 
    • test
      表示dependency作用在測試時,不作用在運行時。
    • system
      跟provided 相似,但是在系統中要以外部JAR包的形式提供,maven不會在repository查找它。 例如:

    <project>
    ...
    <dependencies>
      <dependency>
       <groupId>javax.sql</groupId>
       <artifactId>jdbc-stdext</artifactId>
       <version>2.0</version>
       <scope>system</scope>
       <systemPath>${java.home}/lib/rt.jar</systemPath>
      </dependency>
    </dependencies>
    ...
    </project>

     

    • import (Maven 2.0.9 之后新增)
      它只使用在<dependencyManagement>中,表示從其它的pom中導入dependency的配置,例如:    This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

      <project>

     <modelVersion>4.0.0</modelVersion>

     <groupId>maven</groupId>

     <artifactId>B</artifactId>

     <packaging>pom</packaging>

     <name>B</name>

     <version>1.0</version>

     <dependencyManagement>

        <dependencies>

          <dependency>

            <groupId>maven</groupId>

            <artifactId>A</artifactId>

            <version>1.0</version>

            <type>pom</type>

            <scope>import</scope>

          </dependency>

          <dependency>

            <groupId>test</groupId>

            <artifactId>d</artifactId>

            <version>1.0</version>

          </dependency>

        </dependencies>

     </dependencyManagement>

    </project>

    B項目導入A項目中的包配置

    主站蜘蛛池模板: 久久国内免费视频| 亚洲一区在线观看视频| 日韩精品免费一区二区三区| 久久福利青草精品资源站免费| 亚洲国产精品美女久久久久| 亚洲视频免费一区| 亚洲精品无码永久在线观看你懂的 | 人妻丰满熟妇无码区免费| 免费人成视频在线播放| 学生妹亚洲一区二区| 亚洲老熟女@TubeumTV| 亚洲国产精品无码久久久不卡| 免费夜色污私人影院在线观看| 成人片黄网站A毛片免费| 91人成网站色www免费下载| 国产福利免费视频 | 九九久久国产精品免费热6| 久久人午夜亚洲精品无码区| 国产精品亚洲午夜一区二区三区| 亚洲高清在线播放| 亚洲av永久无码精品秋霞电影影院 | 亚洲精品无码久久久| 国产美女无遮挡免费视频网站 | 亚洲国产精品lv| 亚洲AV无码1区2区久久| 国产亚洲综合久久系列| 亚洲综合图色40p| 成人午夜亚洲精品无码网站| 亚洲精品国产自在久久 | 亚洲av永久无码| 亚洲国产美女精品久久久| 亚洲欧美国产欧美色欲| 亚洲色偷偷综合亚洲av78| 亚洲最大无码中文字幕| 一本色道久久88亚洲精品综合 | 国产男女性潮高清免费网站| 在线观看免费精品国产| 免费在线观看中文字幕| 亚洲人成网站色在线入口| 国产成人99久久亚洲综合精品| 国产成人精品久久亚洲|