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.
System)
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