`
kong6001
  • 浏览: 139762 次
  • 性别: Icon_minigender_1
  • 来自: 广东广州
社区版块
存档分类
最新评论

Maven-Maven Dependency 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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics