
Maven Tutorial for Beginners From pom to Package and Test
Create a Maven project, read the pom, add a dependency and a test, then build a jar with one command and understand the directory layout.
Tag
9 posts

Create a Maven project, read the pom, add a dependency and a test, then build a jar with one command and understand the directory layout.

What compile, provided, runtime and test scopes mean, which classpaths each one joins, how scope changes transitively and where the import scope fits.

How Maven picks one version when libraries disagree, why nearest definition wins, how to see the conflicts and pin a version with dependencyManagement.

Use dependencyManagement and a bill of materials in Maven to align library versions: import scope, the Spring Boot BOM, overriding and writing your own BOM.

Work through why Maven cannot resolve a dependency: a wrong coordinate, a cached failure, a blocked mirror, missing credentials or a proxy.

Read the maven-compiler-plugin failure to its real cause: a JRE instead of a JDK, a release the JDK lacks, annotation processing or a real compile error.

Generate a Java client or server interfaces from an OpenAPI spec with OpenAPI Generator in Maven and Gradle, and keep generated code out of git.

Fix invalid target release and source option errors by setting maven.compiler.release, updating the compiler plugin and making Maven run on the right JDK.

Fix Maven's JAVA_HOME error by pointing the variable at a JDK directory, not at bin or java, on macOS, Linux and Windows, and verify it with mvn -v.