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
145
votes
8 answers

java.lang.OutOfMemoryError: Java heap space in Maven

When I run maven test, java.lang.OutOfMemoryError happens. I googled it for solutions and have tried to export MAVEN_OPTS=-Xmx1024m, but it did not work. Anyone know other solutions for this problem? I am using maven 3.0 Paste the error message here…
zjffdu
  • 25,496
  • 45
  • 109
  • 159
145
votes
34 answers

Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

I have installed a latest maven-3.0.4 on Windows 7: The installation details are as follows: Installation Path : C:\apache-maven-3.0.4 Environment Variables are: M2_HOME C:\apache-maven-3.0.4\apache-maven\src JAVA_HOME C:\Program…
manofsins
  • 1,583
  • 2
  • 10
  • 12
144
votes
8 answers

How to view maven dependency hierarchy in IntelliJ

I can see the dependency hierarchy in Eclipse. How can I do it in IntelliJ?
zjffdu
  • 25,496
  • 45
  • 109
  • 159
144
votes
17 answers

Maven fails to find local artifact

Occasionally maven complains that a particular dependency, which is built and packaged locally, cannot be found in the local repository while building another project that has it as a dependency. We get an error like: Failed to execute goal on…
user1686620
  • 2,801
  • 4
  • 18
  • 21
143
votes
21 answers

Why am I getting Unknown error in line 1 of pom.xml?

Getting unknown error at Line 1 in pom.xml in Eclipse IDE. It was working fine till yesterday, but all of a sudden after updating my project from master and after fixing merge conflicts getting "Unknown error" in pom.xml. Except me, none of my…
Shravani
  • 1,622
  • 2
  • 11
  • 16
143
votes
6 answers

How to keep Maven profiles which are activeByDefault active even if another profile gets activated?

I have a profile in my pom.xml which should be always active unless it is explicitely deactivated (-P !firstProfile). I solved this by using the activeByDefault flag: firstProfile
Peter
  • 1,471
  • 3
  • 11
  • 4
142
votes
18 answers

How to resolve Unable to load authentication plugin 'caching_sha2_password' issue

In eclipse when i started my application i got this - Could not discover the dialect to use. java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'. at java.sql.SQLException: Unable to load authentication plugin …
Sarath Mohan
  • 1,338
  • 2
  • 10
  • 10
142
votes
3 answers

What is the difference between the Maven Surefire and Maven Failsafe plugins?

What is the difference between Maven Surefire and Maven Failsafe plugins? I have searched all over web, but did not get the answer.
bugCracker
  • 3,656
  • 9
  • 37
  • 58
142
votes
6 answers

'export' is not recognized as an internal or external command

I need to set Maven options in machine. I ran following command and I got 'export' is not recognized as an internal or external command export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
Damith Ganegoda
  • 4,100
  • 6
  • 37
  • 46
142
votes
6 answers

How to get absolute path to file in /resources folder of your project

Assume standard maven setup. Say in your resources folder you have a file abc. In Java, how can I get absolute path to the file please?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
141
votes
5 answers

Why is package-info.java useful?

When I run CheckStyle over my Java project it says Missing package-info.java file. for some classes, but not all of them. I can't really figure out why this message appears only sometimes. Furthermore my project runs perfectly fine without the…
Socrates
  • 8,724
  • 25
  • 66
  • 113
140
votes
5 answers

How to work around the stricter Java 8 Javadoc when using Maven

You'll quickly realize that JDK8 is a lot more strict (by default) when it comes to Javadoc. (link - see last bullet point) If you never generate any Javadoc then of course you'll not experience any problems but things like Maven release process and…
peterh
  • 18,404
  • 12
  • 87
  • 115
140
votes
5 answers

How to remove jar file from local maven repository which was added with install:install-file?

mvn install:install-file -Dfile=phonegap-1.1.0.jar -DgroupId?=phonegap -DartifactId?=phonegap -Dversion=1.1.0 -Dpackaging=jar I use above command to install local jar into maven local repo. Now I have got the dependency from maven repo. I want to…
user1844840
  • 1,937
  • 3
  • 16
  • 13
139
votes
7 answers

If using maven, usually you put log4j.properties under java or resources?

Where should I put the log4j.properties file when using the conventional Maven directories?
user496949
  • 83,087
  • 147
  • 309
  • 426
138
votes
9 answers

How to execute more than one maven command in bat file?

I made a bat file like: mvn clean; mvn package; but it doesn't work, only the first command is executed. can someone help me?
rascio
  • 8,968
  • 19
  • 68
  • 108