Maven---> Learning experience--->maven dependency mechanism (dependency mechanism)

Source: Internet
Author: User

1. Overview:

Dependency management is one of the things Maven excels at and is a feature of Maven.

  reference : 1) MAVEN official website documentation

2)

2.maven dependency mechanism 1) dependencies in Maven are transitive (transitive denpendencies)
          • Pom.xml can inherit from parent Pom.xml
          • Other projects on which the project relies on three-party engineering (dependencies) dependencies can be automatically inherited
          • Because Maven manages the project, its dependencies are transitive, so it's easy to have a problem that relies on the possibility of forming a loop (cycle)
2) Dependency scope dependent range is controllable

There is 6 scopes available:

        • Compile (default)
          This is the default scope, and used if none is specified "specified". Compile dependencies is available in all classpaths of a project. Furthermore, those dependencies is propagated "propagate" to dependent projects.
        • Provided
          This was 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 was only available on the compilation and Test Classpath, and was not transitive.
        • Runtime
          This scope indicates the dependency is not a required for compilation and is a for execution. It is in the runtime and test classpaths, but not the compile classpath.
        • Test
          This scope indicates the dependency are not required for normal use of the application, and are only available for the Test compilation and execution phases. This scope is not transitive.
        • System
          This scope was similar to provided except so you had to provide the JAR which contains it explicitly "explicitly". The artifact are always available and are not looked up in a repository.
        • Import (only available in Maven 2.0.9 or later)
          This scope is only supported on a dependency for type pom in the <dependencyManagement> section. It indicates the dependency to being replaced with the effective list of dependencies in the specified "specified" POM ' s <dep Endencymanagement> section. Since They is replaced, dependencies with a scope of import does not actually participate in limiting the Transiti Vity of a dependency.
2) How to add external to your project through MAVEN pom.xml dependencies

Maven---> Learning experience--->maven dependency mechanism (dependency mechanism)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.