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.

  • 相关阅读:
    python入门的120个基础练习
    python日志打印模块
    自动化测试总结
    Http_requests
    安装electron-ssr出现的问题
    豆瓣油猴脚本
    ubuntu 16.04 無法進入tty1-6(未解決)
    如何用firefox chrome chromium看只支持IE浏览器的视频 通过wine 安装IE
    python reverse 和reversed
    python 编码问题
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/12550634.html
Copyright © 2011-2022 走看看