Questions tagged [maven]

Apache Maven is a build automation and project management tool used primarily for Java projects. This tag is for questions that don't relate to a specific Maven version. Use the gradle tag instead for questions relating to Gradle.

Apache Maven is a build automation tool used primarily for Java projects. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information.

Maven's objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. Maven adheres to the principle of "convention over configuration" that helps building Maven projects with very little configuration. Systems, libraries, and frameworks should assume reasonable defaults, and systems should "just work" without requiring unnecessary configuration. In order to attain this goal, there are several areas of concern that Maven attempts to deal with:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features

The configuration of a Maven project is done by creating a file called pom.xml located at the root of the project. This file is referred to as the POM file. Each POM file inherits from a global Super POM that defined common properties for all Maven projects.

If you see questions with this tag that specifically refer to the Maven versions 2.x, 3.x (or the legacy 1.x), please re-tag them with , and , respectively.

If you see questions related to a specific Maven plugin, please also check whether the related plugin tag is present (i.e. , ).

Questions related to Maven plugin development should also have the , while questions related to Maven profiles should also have the tag, and questions related to Maven archetypes should also have the tag.

More information

Free Maven Books

Frequently Asked Questions:

People often ask about the following topics:

General:

Maven Repository:

87627 questions
174
votes
9 answers

What is the difference in Maven between dependency and plugin tags in pom.xml?

Created project with Spring, Hibernate & Maven. My question is what is the logic behind plugin versus dependency ?
Soumyaansh
  • 8,626
  • 7
  • 45
  • 45
172
votes
3 answers

Specifying Maven's local repository location as a CLI parameter

Is it possible to set the location of the local Maven repository as argument on the Maven command line? The thing is that I don't use the default one in ~/.m2/repository. However I checked out some project that is being built with its own settings…
lisak
  • 21,611
  • 40
  • 152
  • 243
172
votes
8 answers

How to tell Maven to disregard SSL errors (and trusting all certs)?

I frequently need to run "mvn" command : mvn -f pom.xml clean install -Dmaven.test.skip=false --settings /Users/myhome/settings.xml -X -Djavax.net.ssl.trustStore=/Users/myhome/truststore.jks -Djavax.net.ssl.trustStoreType=JKS…
Novice User
  • 3,552
  • 6
  • 31
  • 56
171
votes
23 answers

Error "Source option 5 is no longer supported. Use 6 or later" on Maven compile

I am getting the following error on $ mvn compile: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Sym360: Compilation failure: Compilation failure: [ERROR] Source option 5 is…
SUPARNA SOMAN
  • 2,311
  • 3
  • 19
  • 35
169
votes
18 answers

Maven Could not resolve dependencies, artifacts could not be resolved

This is supposed to be a working project from my friend. He demonstrated the project right in front of me, and then I copied the project, imported it as an existing maven project (I'm using m2eclipse plugin). And then, this error occurs. This error…
Bertie
  • 17,277
  • 45
  • 129
  • 182
168
votes
6 answers

'parent.relativePath' points at my com.mycompany:MyProject instead of org.apache:apache - Why?

What is true is that Solr project directory is inside MyProject parent directory (but there's no module or any maven relationship between the 2, just FS convenience). Do I have to place it out? $ mvn -DskipTests clean install [INFO] Scanning for…
simpatico
  • 10,709
  • 20
  • 81
  • 126
168
votes
12 answers

How do I force Maven to use my local repository rather than going out to remote repos to retrieve artifacts?

I’m using Maven 3.3.3 with Java 8 on Mac Yosemite. I have a multi-module project. first-module my-module When I build my one of my child…
Dave
  • 15,639
  • 133
  • 442
  • 830
168
votes
32 answers

Why am I getting a "401 Unauthorized" error in Maven?

Why am I getting a "401 Unauthorized" error in Maven? Here's the error I'm getting when calling mvn deploy (full logs at the bottom): [INFO] BUILD FAILURE [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy…
aliteralmind
  • 19,847
  • 17
  • 77
  • 108
167
votes
9 answers

Why Maven uses JDK 1.6 but my java -version is 1.7

I have setup maven in my terminal, and when getting the version settings (using mvn -v) it seems it uses JDK 1.6, while I have JDK 1.7 installed. Is there anything wrong? The commands I enter are these: blues:helloworld Ninja$ java -version java…
Ninja
  • 2,479
  • 3
  • 23
  • 32
167
votes
3 answers

What does Maven do, in theory and in practice? When is it worth to use it?

I am about to start a Java project just for practice. I've read about Maven, but I don't actually understand when it is meant to be used. Can you give me some practical tips? Does Maven help a lot? What does Maven actually do for my project?
Piotr Krysiak
  • 2,815
  • 3
  • 23
  • 35
166
votes
17 answers

How do I use Maven through a proxy?

I want to share my experience of using maven through a proxy. You would most likely face exceptions and messages like: repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error…
Bogdan
  • 1,995
  • 2
  • 14
  • 12
164
votes
7 answers

How to dockerize maven project? and how many ways to accomplish it?

I am new to Docker, and don't know how to run a java project with maven even though I have read many documents and tried many methods. Should I build the image using Dockerfile? What is the commands like when it is to run the maven project in the…
Yashon Lin
  • 1,845
  • 2
  • 13
  • 10
164
votes
35 answers

Why so red? IntelliJ seems to think every declaration/method cannot be found/resolved

I just installed and re-installed IntelliJ. Every Java file is coming up RED. I checked the JDK; it is at 1.6.##. The maven clean install build worked just fine. I'm getting the usual highlighted errors. On every declaration: Cannot resolve symbol…
iCodeLikeImDrunk
  • 17,085
  • 35
  • 108
  • 169
163
votes
10 answers

Why am I getting "Received fatal alert: protocol_version" or "peer not authenticated" from Maven Central?

I'm getting the below errors when connecting to Maven Central / https://repo1.maven.org after June 18th 2018. Received fatal alert: protocol_version or Received fatal alert: peer not authenticated
Brian Fox
  • 6,782
  • 4
  • 27
  • 31
163
votes
34 answers

Intellij idea cannot resolve anything in maven

I just imported a project with pom.xml, but the IDE didn't resolve anything in maven dependencies. Anything defined in pom.xml dependencies when import in code raise an error cannot resolve symbol xxxxx But mvn install will work, I try import the…
Burst
  • 1,755
  • 2
  • 11
  • 7