Skip to main content

Maven




Installing:

Download latest Maven from:
http://maven.apache.org

Dependencies:

First looked for local, and then on Maven central

Scopes:

There are 6 scopes, but mostly 4 are used:
  • compile
  • runtime
  • test
  • provided
  • system
  • import

Compile Scope (default scope)


Used for compilation and execution. The artifacts are included in containers, e.g. war/ear file, while packaging.

Runtime Scope

Used for deployment and runtime, but not for compilation. The artifacts are included in containers, e.g. war/ear file, while packaging.


Test Scope

Used *only* for test execution, but not included during compilation or execution.


Provided Scope

Specifies that the execution environment will provide the artifacts, e.g. j2ee related jars provided by J2EE container itself.


System Scope:


Very rarely used. Specifies that the artifacts will be looked for in the local system itself. It is not recommended to use this scope, as it defeats the main purpose of loading dependencies itself.


Import Scope:

Almost never used. It replaces the already loaded artifacts.


Inserting Dependencies:


Go to "Maven Central", and search for the dependency artifact inside:
https://search.maven.org

Listing Dependency Tree:


cmd> mvn dependency:tree




Comments