maven dependency scope

compile (compile scope)

compile is the default scope; if no scope is provided, the dependency's scope is the compile scope. Compile-scoped dependencies are available on all classpaths, and they are also packaged. This dependency is also added when (mvn package)

It means: the compilation scope is valid and will be stored in the compilation and packaging.

 

provided

A provided dependency is only used when the JDK or a container has provided the dependency. For example, if you develop a web application, you may need the Servlet API available on the compile classpath to compile a servlet, but you would not want to include the Servlet API in the packaged WAR; the Servlet API JAR is provided by your Provided by the application server or servlet container. Scoped dependencies are available on the compile classpath (not runtime). They are not transitive and will not be packaged when mvn package is executed.

 

runtime (runtime scope)

Runtime dependencies are needed when running and testing the system, but not at compile time. For example, you might only need the JDBC API JAR at compile time, and only need the JDBC driver implementation at runtime. That is, it will depend on it at runtime, not at compile time

 

test (test scope)

Test-scoped 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 compilation based on native objects that 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 set a dependency scope to be system scope, you must also provide a systemPath element. Note that this scope is deprecated (you should always try to reference dependencies from public or custom Maven repositories).

Guess you like

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