Files
framework_note/devop_note/video/Learn Apache Maven Full Tutorial in Java for Beginners.md
T
2026-05-30 16:02:33 -04:00

3.5 KiB

tags, up, related, source, author, published
tags up related source author published
devop
video
maven
java
00_devop_note Maven https://www.youtube.com/watch?v=T00NKLQvwYE Cameron McKenzie (TheServerSide) 2023-08-27

Learn Apache Maven Full Tutorial in Java for Beginners

An hour-long beginner-friendly course that walks through Apache Maven from scratch — installation, configuration, core commands, dependencies, plugins, and integrations with Jenkins and Docker.

Overview

Apache Maven is the most widely used build automation tool in the Java ecosystem (used by ~70% of Java organizations). This tutorial progresses from foundational concepts (installing Java/JDK and Maven) through to advanced topics like building cloud-native microservices and CI/CD integration.

Topics Covered

1. Getting Started

  • What Maven is and what it enables developers to do
  • Installing the JDK (prerequisite)
  • Downloading, installing, and configuring Maven
  • Verifying the install with mvn -v

2. Core Maven Commands

  • mvn compile — compile source code
  • mvn test — run unit tests
  • mvn package — bundle compiled code into a JAR/WAR
  • mvn install — install artifact into local repo
  • mvn deploy — push artifact to a remote repo
  • mvn clean — wipe the target/ directory

3. The POM File (pom.xml)

  • The heart of every Maven project
  • POM types (parent, aggregator, effective POM)
  • Properties and how they control build behavior
  • Project coordinates: groupId, artifactId, version

4. Dependency Management

  • Declaring dependencies
  • Scopes: compile, provided, runtime, test, system
  • External dependencies
  • Exclusions and optional dependencies
  • How Maven resolves transitive dependencies

5. Plugins

  • Plugins extend Maven's core functionality
  • Commonly used:
    • Compiler Plugin — controls the Java source/target version
    • Surefire Plugin — runs unit tests
  • When to add a plugin vs. rely on defaults

6. Maven vs. Gradle

  • Comparison of the two dominant JVM build tools
  • Tradeoffs: XML configuration (Maven) vs. Groovy/Kotlin DSL (Gradle)
  • Why Maven still dominates enterprise Java

7. IDE Integration

  • Creating and managing Maven projects in IntelliJ IDEA and Eclipse
  • Building projects from the IDE
  • Creating executable JARs
  • Handling multi-module projects

8. DevOps Integration

  • Maven + Jenkins — running builds in CI pipelines
  • Maven + Docker — packaging artifacts into Docker images
  • Building cloud-native microservices

Key Takeaways

  • Maven is opinionated — follow the standard directory layout (src/main/java, src/test/java) and most things just work
  • The pom.xml is declarative; you describe what the project is, not how to build it
  • Dependency scopes matter — using test scope keeps test libraries out of production artifacts
  • Plugins are how Maven gets extended; nearly every advanced behavior is plugin-driven

Actionable Next Steps

  • Install JDK and Maven; verify with mvn -v
  • Generate a starter project: mvn archetype:generate
  • Try the full lifecycle: mvn clean package
  • Add a dependency from Maven Central
  • Wire a simple project into Jenkins or Docker

Source