Skip to content
Tutorials Center
My learning

Topics

Maven Tutorial

Learn Maven step by step: 41 lessons in 11 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Maven? Learn what Apache Maven is, which build problems it solves, how convention over configuration works, and how it compares with Ant and Gradle.
  2. 2 Installing Maven and the Wrapper Install a JDK and Apache Maven on Windows, macOS or Linux, set JAVA_HOME, check mvn -v, and use the Maven Wrapper so every machine builds with the same version.
  3. 3 Maven in IntelliJ IDEA, Eclipse and VS Code Create a Maven project in IntelliJ IDEA or Eclipse, import an existing one, reload after POM changes, run goals from the IDE and fix the usual JDK and sync problems.
  4. 4 Your First Maven Project Generate a Maven project from an archetype, read the resulting folders, build a hello-world JAR with mvn package and understand every line of the console output.
  5. 5 The Standard Directory Layout Learn every folder in a Maven project: src/main/java, src/main/resources, src/test, and target. See why the convention matters and how resource filtering works.

The POM

  1. 6 The POM File Understand the Maven pom.xml: the project root, modelVersion, coordinates, packaging, name and description, dependencies and the idea of an effective POM.
  2. 7 Coordinates: groupId, artifactId, version Learn Maven GAV coordinates: naming rules for groupId and artifactId, how versions are ordered, SNAPSHOT versus release, and why version ranges are risky.
  3. 8 Properties and Build Settings Use Maven properties and ${...} interpolation, set UTF-8 encoding and maven.compiler.release, and configure a Java 25 build that behaves the same everywhere.
  4. 9 Parent POMs and the Effective POM Learn how Maven POM inheritance works: the parent element, the Super POM, relativePath, what children inherit, and how to inspect the result with help:effective-pom.

Lifecycle and Plugins

  1. 10 Lifecycles and Phases Understand Maven's three lifecycles (default, clean, site), every phase from validate to deploy, and why running one phase also runs all the phases before it.
  2. 11 Plugins and Goals Learn how Maven plugins and goals work: the plugin:goal syntax, default bindings per packaging, mvn compile versus compiler:compile, executions and pluginManagement.
  3. 12 The Core Plugins in Practice Configure Maven's core plugins in practice: compiler (release vs source/target), resources filtering, surefire, jar, clean, install and deploy, with safe settings.
  4. 13 Documents with Maven: Asciidoctor and Apache POI Generate HTML or PDF documentation from AsciiDoc with the Asciidoctor Maven plugin, create PowerPoint files with Apache POI, and run the code from Maven with exec.
  5. 14 The Command Line Toolbox Learn the Maven command-line options you use daily: -D, -P, -pl, -am, -T, -o, -q, -X, -DskipTests, -rf and -ntp, and how to read logs and stack traces.

Dependencies

  1. 15 Adding Dependencies Learn how the Maven dependency element works, how to find a library on Maven Central, add it to your POM, refresh your IDE and fix missing-dependency errors.
  2. 16 Dependency Scopes Understand Maven dependency scopes: compile, provided, runtime, test, system and import, which classpath each one joins, and how scope changes transitively.
  3. 17 Transitive Dependencies and Mediation See how Maven pulls in transitive dependencies, how nearest-wins and first-declaration pick one version, and how exclusions and optional dependencies change the graph.
  4. 18 Managing Versions: dependencyManagement and BOMs Control library versions in one place with dependencyManagement, import-scope BOMs like Spring Boot and Jackson, version properties and the enforcer convergence rule.
  5. 19 Diagnosing Dependency Conflicts Find and fix Maven dependency conflicts with dependency:tree -Dverbose and dependency:analyze, understand NoSuchMethodError and classpath hell, and when to shade.

Repositories

  1. 20 Repositories and the Local Cache Learn how Maven repositories work: the ~/.m2 local cache, Maven Central, how a GAV becomes a file path, checksums, update policies and offline mode.
  2. 21 settings.xml, Mirrors and Credentials Configure Maven per machine with settings.xml: user and global files, mirrors, proxies, server credentials, password encryption and a Nexus or Artifactory proxy.

Testing and Quality

  1. 22 Running Tests with Surefire Run JUnit tests from Maven with the Surefire plugin: dependency setup, naming patterns, -Dtest filters, skipTests versus maven.test.skip, and test reports.
  2. 23 Testing with JUnit and Mockito in a Maven project Add JUnit and Mockito to a Maven project with the right scopes, write unit tests with mocks, stubs, verification and captors, and run them with Surefire.
  3. 24 Integration Tests with Failsafe Separate slow integration tests from unit tests with the Maven Failsafe plugin: IT naming, the verify phase, why two plugins exist, and how to run and skip them.
  4. 25 Code Quality: Coverage and Static Checks Add quality gates to a Maven build: JaCoCo coverage thresholds, Checkstyle, SpotBugs, the Enforcer plugin and formatter plugins, and fail the build on violations.

Packaging and Multi-module

  1. 26 Packaging: JAR, WAR and Executable Jars Choose the right Maven packaging: jar, war and pom, the MANIFEST Main-Class entry, and how Shade, Assembly and the Spring Boot plugin build a runnable fat jar.
  2. 27 Multi-Module Builds and the Reactor Split a Maven project into modules: aggregator POMs, the reactor build order, inter-module dependencies, -pl and -am, and inheritance versus aggregation.
  3. 28 Profiles and Environments Learn how Maven profiles switch build settings by property, JDK, OS or file, how resource filtering works per environment, and the pitfalls to avoid.

Releasing and Production

  1. 29 Publishing: Install, Deploy and Maven Central Understand the difference between mvn install and mvn deploy, how to configure distributionManagement, sign artifacts with GPG and publish to Maven Central.
  2. 30 Release Workflows and Reproducible Builds Automate Maven releases with the release and versions plugins, use CI-friendly ${revision} versions and make builds reproducible with outputTimestamp.
  3. 31 Maven in CI and Faster Builds Run Maven on GitHub Actions, cache the local repository, build modules in parallel with -T, use mvnd and the build cache extension, and model build times.
  4. 32 Writing a Simple Maven Plugin Write your own Maven plugin: the maven-plugin packaging, a Mojo class with @Mojo and @Parameter, the generated descriptor, phase binding and testing.
  5. 33 Dependency Security and Supply Chain Protect a Maven build from vulnerable and malicious dependencies: OWASP dependency-check, Dependabot and Renovate, checksums, signatures and enforcer rules.

Alternatives and Migration

  1. 34 Maven vs Gradle Compare Maven and Gradle: declarative XML versus scripted builds, speed, ecosystem, when to pick each, and how a pom.xml maps to a build.gradle file.
  2. 35 Troubleshooting Common Maven Errors Read Maven failures like a pro: wrong Java version, missing dependencies, plugin not found, stale cache, certificate, proxy and out-of-memory errors, with fixes.

Projects

  1. 36 Project: A Reusable Library Build a small Java library with Maven: tests, sources and javadoc jars, install it into your local repository, then use it from a second project.
  2. 37 Project: A Multi-Module Application Build a three-module Maven application with a parent POM, managed versions, a BOM import and a runnable jar, and watch the reactor order and classpath.
  3. 38 Project: A CI Pipeline for a Maven Project Set up GitHub Actions for a Maven project: build and test on every push, cache dependencies, report coverage, and release on a version tag.

Practice and Review

  1. 39 Practice Exercises with Solutions Twelve graded Maven exercises on POMs, scopes, dependency mediation, profiles, versions and reactor order, with full solutions and runnable checkers.
  2. 40 Maven Interview Questions Prepare for a Maven interview: lifecycle phases, dependency scopes, mediation, dependencyManagement, SNAPSHOT versions, profiles and multi-module builds, with short answers.
  3. 41 Maven Cheat Sheet One-page Maven cheat sheet: everyday commands, lifecycle phases, dependency scopes, a POM skeleton, command-line flags and a troubleshooting table for common build errors.