Backend Development 17 min read

Maven Basics: Configuration, Dependency Management, Modules, Plugins, and Build Settings

This article provides a comprehensive guide to Maven, covering repository configuration, basic project setup, dependency declaration and management, module organization, unified version control, essential plugins such as jar, assembly, and shade, as well as build settings like compiler version, resource exclusion, and main class definition.

Top Architect
Top Architect
Top Architect
Maven Basics: Configuration, Dependency Management, Modules, Plugins, and Build Settings

1. Basic Configuration

Maven introduces the concept of repositories; dependencies are downloaded from the central repository to the local repository, and private repositories can be added for internal use.

2. Dependency Management

Dependencies are declared using groupId , artifactId , and version . The dependencies tag adds direct dependencies, while Maven resolves transitive dependencies automatically.

Dependency order follows the "first defined, first imported" principle, and version conflicts are resolved based on declaration order.

Conflicts can be avoided using excludes or marking a dependency as optional .

3. Variable Configuration

Common versions can be defined in a properties section and referenced with ${...} .

4. Module Configuration

Multi‑module projects use the modules tag; child modules inherit groupId and version from a parent POM via the parent element.

5. Unified Management

The dependencyManagement section in a parent POM centralises version definitions, allowing child modules to declare dependencies without specifying versions.

6. Plugin Management

Common plugins include maven-jar-plugin for JAR metadata, maven-assembly-plugin to bundle dependencies, and maven-shade-plugin for creating uber JARs with relocation and filtering.

7. Build Configuration

The maven-compiler-plugin sets the Java source/target version, resources can be excluded from the JAR, and the main class can be defined via the appropriate plugin configuration.

Javadependency managementMavenBuild ToolsPluginsModules
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.