Compile
The package is considered in the build. If there is packaging, the dependency is included in the package.
Provided
The package is considered in the compilation, but is not included in the package if there is packaging.
Import
Only works for dependencies like POM
in part <dependencyManagement>
of your file pom.xml
. Basically includes all dependencies contained within the POM
of dependence on their POM
.
Runtime
Indicates that the dependency does not need to be in the build, but needs to be in the run.
Test
Indicates dependency is only used in the test phase.
System
Similar to provided
, but for Jars. Jars need to be explicitly specified.
More here: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
On what to take into account for the use of each, this becomes clearer as you package your application and some errors appear. For example, the scope provided
is well used when packages belong to some lib
standard of a specific application server, such as Jboss or Weblogic, where packages do not exist in a Maven repository, but they need to be validated at some stage of development.
First of all, thank you for answering. A curiosity, well-known application servers like Wildfly, Glassfish, Weblogic, etc., present all Javaee technologies(JPA, JTA, EJB, JSF, etc.)? Or each server has only some of these Javaee technologies?
– klaytonbrito
Each has a variety of technologies depending on the version of each server. It is worth consulting the specification pages, inclusive, to save on making your POM.
– Leonel Sanches da Silva