| Type | Purpose |
|---|---|
| Super POM | Maven default; all projects inherit it |
| Parent POM | Shares config across modules; enforces versions |
| BOM | Version lookup table only; imported via scope=import |
| Effective POM | Final merged result (project + parent + BOM + super) |
| Command | Action |
|---|---|
| mvn clean | Delete /target |
| mvn compile | Compile src |
| mvn test | Run unit tests |
| mvn package | Build JAR/WAR |
| mvn install | Install to local repo |
| mvn deploy | Deploy to remote |
| mvn clean install | Full clean build |
| mvn clean install -U | Force dependency update |
| mvn -DskipTests | Skip test execution (compile only) |
| mvn -Dmaven.test.skip=true | Skip compile + execution |
| mvn dependency:tree | Show dep tree |
| mvn -P prod | Activate profile |
| mvn spring-boot:run | Run Spring Boot app |
| mvn exec:java | Run Java program |
| mvn site | Generate project site |
| Phase | Plugin : Goal bound by default |
|---|---|
| process-resources | resources:resources |
| compile | compiler:compile |
| process-test-resources | resources:testResources |
| test-compile | compiler:testCompile |
| test | surefire:test |
| package | jar:jar (or war:war) |
| verify | failsafe:verify |
| install | install:install |
| deploy | deploy:deploy |
| clean | clean:clean |
| Scope | Compile | Runtime | Test | In JAR? |
|---|---|---|---|---|
| compile (default) | ✓ | ✓ | ✓ | ✓ |
| provided | ✓ | ✗ | ✓ | ✗ |
| runtime | ✗ | ✓ | ✓ | ✓ |
| test | ✗ | ✗ | ✓ | ✗ |
| Goal | Phase | Does | Direct cmd |
|---|---|---|---|
| compiler:compile | compile | Compiles src/main/java | mvn compiler:compile |
| compiler:testCompile | test-compile | Compiles src/test/java | mvn compiler:testCompile |
| Goal | Phase | Does | Direct cmd |
|---|---|---|---|
| surefire:test | test | Runs JUnit / TestNG unit tests, generates XML/txt reports in target/surefire-reports | mvn surefire:test |
| Goal | Phase | Does | Direct cmd |
|---|---|---|---|
| failsafe:integration-test | integration-test | Runs *IT.java tests | mvn failsafe:integration-test |
| failsafe:verify | verify | Checks if IT tests passed; fails build here (not mid-test) | mvn failsafe:verify |
| Plugin : Goal | Phase | Output | Direct cmd |
|---|---|---|---|
| jar:jar | package | Thin JAR (no deps) | mvn jar:jar |
| shade:shade | package | Fat/Uber JAR (all deps merged) | mvn package |
| assembly:single | package | Custom zip/tar/dir distribution | mvn assembly:single |
| war:war | package | WAR file (web apps) | mvn war:war |
| Goal | Does | Direct cmd |
|---|---|---|
| dependency:tree | Print full dependency tree | mvn dependency:tree |
| dependency:analyze | Find unused/undeclared deps | mvn dependency:analyze |
| dependency:copy-dependencies | Copy all dep JARs to a folder | mvn dependency:copy-dependencies |
| dependency:unpack | Extract a dep's contents | mvn dependency:unpack |
| Goal | Phase | Does | Direct cmd |
|---|---|---|---|
| spring-boot:repackage | package | Rewraps JAR into executable fat JAR | mvn package |
| spring-boot:run | — | Start app without building JAR | mvn spring-boot:run |
| spring-boot:build-image | — | Build OCI/Docker image (Buildpacks) | mvn spring-boot:build-image |
| Plugin : Goal | Phase | Does | Direct cmd |
|---|---|---|---|
| exec:java | — | Run main() class directly | mvn exec:java |
| exec:exec | — | Run any shell command | mvn exec:exec |
| clean:clean | clean | Delete /target dir | mvn clean:clean |
| install:install | install | Copy artifact to ~/.m2 | mvn install:install |
| deploy:deploy | deploy | Push artifact to remote repo | mvn deploy:deploy |
| release:prepare | — | Strip -SNAPSHOT, tag in Git | mvn release:prepare |
| release:perform | — | Build & deploy tagged release | mvn release:perform |
| versions:set | — | Update version in pom.xml | mvn versions:set -DnewVersion=2.0 |
| File | Controls |
|---|---|
| pom.xml | What project needs (deps, plugins, repos) |
| settings.xml | How Maven behaves (auth credentials, mirrors, local repo location, global repos) |
| Problem | Fix |
|---|---|
| Missing artifact | Verify GAV coords → mvn clean install -U |
| Version conflict | mvn dependency:tree → add exclusion or pin in depMgmt |
| Corrupt local cache | Delete ~/.m2/repository or run -U |
| Can't find artifact | Check company Nexus/Artifactory |
| Debug build | mvn -X for full stack trace |
| Test failures blocking | -DskipTests or use fast-build profile |