• 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.

  • 相关阅读:
    bat学习
    Eclipse调试方法及快捷键
    JDK中的设计模式
    开源-自由-乔布斯
    AOP
    编程语言
    [LeetCode] 160. Intersection of Two Linked Lists(两个单链表的交集)
    [LeetCode] 198. House Robber(小偷)
    [LeetCode] 155. Min Stack(最小栈)
    [LeetCode] 1. Two Sum(两数之和)
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/12550634.html
Copyright © 2020-2023  润新知