zoukankan      html  css  js  c++  java
  • Maven使用

    maven 传递依赖机制

    http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

    当遇到多个版本作为依赖关系时,maven 将选择哪个版本作为真正的依赖呢? Maven选择了“最近的定义”。也就是说,它使用依赖关系树中最接近您的项目的版本。您始终可以通过在项目的POM中明确声明版本来保证版本。请注意,如果两个依赖关系版本在依赖关系树中的深度相同,则第一个声明将获胜。 例如,如果将A,B和C的依存关系定义为A-> B-> C-> D 2.0和A-> E-> D 1.0,则在构建A时将使用D 1.0,因为从A的路径通过E到D的时间更短。您可以在A中向D 2.0显式添加一个依赖项,以强制使用D 2.0。

     

    Dependency Scope(依赖范围)

    • compile This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

    • provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

    • runtime This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

    • test This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.(此范围不是可传递的。)

    • system This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

    • import This scope is only supported on a dependency of type pom in the <dependencyManagement> section. It indicates the dependency to be replaced with the effective list of dependencies in the specified 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.

  • 相关阅读:
    HTML中的文本标签
    Java 数组的创建
    JavaScript实现LUHN算法验证银行卡号有效性
    JavaScript实现HTML页面集成QQ空间分享功能
    JavaScript中的三种弹出框的区别与使用
    Maven 项目中的 pom.xml 文件内容说明
    FTPClient 中 FTPClient.changeWorkingDirectory(filePath) 代码一直返回 false
    Eclipse 中 Debug 时鼠标悬停无法查看变量值
    Innodb ,MyISAM
    tomcat jetty
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/12550634.html
Copyright © 2011-2022 走看看