Maven dependency scope label usage

Source: Internet
Author: User

In a Maven project, if a jar package is required for compilation but not required for release, you can use the scope label with the value set to provided. As follows:

<Dependency> <groupid> javax. servlet. JSP </groupid> <artifactid> JSP-API </artifactid> <version> 2.1 </version> <scope> provided </scope> <classifier/> </dependency>

Other parameters of scope are as follows:

Compile
The default scope indicates that dependency can be used in the lifecycle. In addition, these dependencies are passed to the dependent project. Applicable to all stages and will be released along with the Project
Provided
Similar to compile, but it indicates that dependency is provided by JDK or container, such as servlet AP and some java EE APIs. This scope can only be used during compilation and testing without passing .????????
Runtime
It indicates that dependency does not work during compilation, but does work during running and testing, such as the JDBC driver, applicable to the running and testing stages.
Test
It indicates that dependency is used for testing and does not work for running. It is only used for testing and is used to compile and run the test code. Will not be released along with the project.
System
Similar to provided, but it must be provided in the form of external jar packages in the system. MAVEN will not find it in repository.

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.