(Transfer) Explanation of the meaning of maven scope

Dependency scope controls which dependencies are available on which classpath and which dependencies are included in an application. Let's look at each scope in detail:
 
compile (compile scope)
 
compile is the default scope; if no scope is provided, the dependency's scope is the compile scope. compile-scope dependencies are available on all classpaths,

At the same time they will also be packaged.
 
provided (scope provided) A
 
provided dependency is used only after the dependency has been provided by the JDK or a container. For example, if you develop a web application, you may be compiling

The Servlet API needs to be available on the classpath to compile a servlet, but you wouldn't want to include the Servlet API in the packaged WAR; this

The Servlet API JAR is provided by your application server or servlet container. Provided scoped dependencies are available on the compile classpath (not runtime). they

Not transitive and not packaged.
 
runtime (runtime scope)
 
runtime dependencies are required when running and testing the system, but not when compiling. For example, you might only need the JDBC API JAR at compile time, and only

A JDBC
 driver implementation is only required at runtime.
 
test (test scope)
 
test scope dependencies are not needed at normal compile and run time, they are only available during the test compile and test run phases.
 
system (system-wide)
 
system-wide dependencies are similar to provided, but you must explicitly provide a path to the JAR file on the local system. This is done to allow local-based

Objects are compiled, and these objects are part of the system class library. Such an artifact should always be available and Maven will not look for it in the repository. if you put a

依赖范围设置成系统范围,你必须同时提供一个 systemPath 元素。注意该范围是不推荐使用的(你应该一直尽量去从公共或

定制的 Maven 仓库中引用依赖)。

 

转自:http://blog.csdn.net/ld513508088/article/details/23827945

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326227854&siteId=291194637