compile,缺省值娄柳,適用于所有階段争拐,會隨著項目一起發(fā)布。
compile is the default scope; all dependencies are compile-scoped if a scope is not supplied.compile dependencies are available in all classpaths, and they are packaged.provided蝗岖,類似compile侥猩,期望JDK、容器或使用者會提供這個依賴抵赢。如servlet.jar欺劳。
provided dependencies are used when you expect the JDK or a container to provide them. For example, if you were developing a web application, you would need the Servlet API available on
the compile classpath to compile a servlet, but you wouldn’t want to include the Servlet API in the packaged WAR; the Servlet API JAR is supplied by your application server or servlet container.
provided dependencies are available on the compilation classpath (not runtime). They are not transitive, nor are they packaged.runtime,只在運行時使用铅鲤,如JDBC驅(qū)動划提,適用運行和[測試]階段。
runtime dependencies are required to execute and test the system, but they are not required for compilation. For example, you may need a JDBC API JAR at compile time and the JDBC driver implementation only at runtime.test邢享,只在測試時使用腔剂,用于編譯和運行測試代碼。不會隨項目發(fā)布驼仪。
test-scoped dependencies are not required during the normal operation of an application, and they are available only during test compilation and execution phases.system掸犬,類似provided,需要顯式提供包含依賴的jar绪爸,Maven不會在Repository中查找它湾碎。
The system scope is similar to provided except that you have to provide an explicit path to the JAR on the local file system. This is intended to allow compilation against native objects that may
be part of the system libraries. The artifact is assumed to always be available and is not looked up in a repository. If you declare the scope to be system, you must also provide the systemPath
element. Note that this scope is not recommended (you should always try to reference dependencies
in a public or custom Maven repository).
The second dependency is a test-scoped dependency on JUnit. You would use a testscoped dependency when you need to reference this library only during testing.
The last dependency in Project Dependencies is a dependency on the Servlet 2.4 API. The last dependency is scoped as a provided dependency. You would use a provided scope when the application you are developing needs a library for compilation and testing, but this library is supplied by a container at runtime.