- manage multiple jars
- dependencies and versions
- project structure
- build, publish and deploy
Details in pom.xml
- Archetype: project structure/template/type. for example:jee/spring/hibernate
- Group id: package(name) like com.google.xxx
- Artifact id : project name, which is under Gourp id
- Packaging: build type , for example: jar/ear/war
- install: to local maven repository
- deploy: to remote maven repository
- mvn clean: clear all the .class/distributions that generated bofore
- plugin for compiler is customizable: could be 1.4/1.5…etc
- add Jetty plugin and use mvn jetty:run to run project in jetty directly. use <scanIntervalSeconds> for hot deploy in <build><configuration>
Same thing as tomcat, use mvn tomcat:run for app to run in tomcat
- maven eclipse plugin: in a maven project, use mvn eclipse:ecplise to make it available for eclipse import. it generates the .project file that eclipse would need.
There are 6 scopes available:
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
- import (only available in Maven 2.0.9 or later)
This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that POM’s <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.
the variable in eclipse build option is for defining global pairs of configuration path. for example point the M2_REPO to local customized folder.