Description of Maven Scope

Source: Internet
Author: User

The dependency scope controls which dependencies are available in which classpath and which dependencies are included in an application. Let's take a closer look at each range:
Compile (compilation scope)
Compile is the default range. If no range is provided, the scope of the dependency is the compilation range. The compilation scope dependency is available in all classpath,

They will also be packaged.
Provided (available range)
Provided dependency is used only after JDK or a container provides the dependency. For example, if you develop a web application, you may compile

In classpath, you need to use servlet APIs to compile a servlet, but you do not want to include this servlet API in the packaged war.

Servlet API jar is provided by your application server or servlet container. The provided scope dependency is available when classpath is compiled (not runtime. They

It is not passed and will not be packaged.
Runtime (runtime range)
Runtime dependency is required when running and testing the system, but not during compilation. For example, you may only need jdbc api jar during compilation

JDBC is required only during running.
Driver implementation.
Test (test scope)
The test scope dependency is not required in general compilation and runtime. They are only available in the test compilation and test run stages.
The system range dependency is similar to provided, but you must explicitly provide a path for the JAR file in the local system. This is to allow local-based

Object compilation, and these objects are part of the system class library. Such a component should always be available, and MAVEN will not look for it in the repository. If you

The dependency range is set to the system range. You must provide a systempath element at the same time. Note that this range is not recommended (you should always try to migrate from public or

Reference dependencies in the Custom Maven repository ).

Description of Maven Scope

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