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
324
votes
9 answers

Why use Gradle instead of Ant or Maven?

What does another build tool targeted at Java really get me? If you use Gradle over another tool, why?
IttayD
  • 28,271
  • 28
  • 124
  • 178
323
votes
5 answers

What is pluginManagement in Maven's pom.xml?

This is a snippet of my pom file. .... org.apache.maven.plugins maven-dependency-plugin 2.4
308
votes
21 answers

Find Oracle JDBC driver in Maven repository

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is: com.oracle ojdbc14
rperez
  • 8,430
  • 11
  • 36
  • 44
298
votes
29 answers

How to set specific Java version to Maven?

On my machine I have two Java versions installed: (1.6 and 1.7 installed manually by me). I need both of them for different projects. But for Maven I need 1.7, but my Maven uses the 1.6 Java version. How can I set Maven to use 1.7?
andPat
  • 4,153
  • 7
  • 24
  • 36
296
votes
2 answers

run main class of Maven project

I've created a simple console Java application that is built with Maven. Is there a way that the main class (which doesn't require any arguments) can be run from the command-line using a maven command like: mvn run-app com.example.MainClass
Dónal
  • 185,044
  • 174
  • 569
  • 824
292
votes
16 answers

Make Maven to copy dependencies into target/lib

How do I get my project's runtime dependencies copied into the target/lib folder? As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the runtime dependencies.
Michael
  • 3,049
  • 3
  • 19
  • 5
292
votes
7 answers

How can I disable the Maven Javadoc plugin from the command line?

In pom.xml I have declaration like this org.apache.maven.plugins maven-javadoc-plugin attach-javadocs
IAdapter
  • 62,595
  • 73
  • 179
  • 242
286
votes
6 answers

Maven Run Project

Is there a Maven "phase" or "goal" to simply execute the main method of a Java class? I have a project that I'd like to test manually by simply doing something like "mvn run".
Verhogen
  • 27,221
  • 34
  • 90
  • 109
284
votes
6 answers

Specifying Java version in maven - differences between properties and compiler plugin

I'm not very experienced with Maven and while experimenting with multi-module project I started wondering how can I specify Java version for all my child modules in parent Maven pom. Until today I was using just:
Plebejusz
  • 3,332
  • 2
  • 19
  • 26
284
votes
2 answers

How do I enable index downloads in Eclipse for Maven dependency search?

I am using Eclipse Luna with the m2e plug-in. When I search for dependencies, I get the following warning (also see the screenshot after): Index downloads are disabled, search result may be incomplete. How can I enable index downloads?
Ashish
  • 14,295
  • 21
  • 82
  • 127
282
votes
32 answers

'react-scripts' is not recognized as an internal or external command

I've got a maven project, within which is JavaScript project cloned as a git sub-module. So the directory structure looks like mavenapp/src/main/javascript/[npm project files] Inside my package.json, the test looks like this: "test": "react-scripts…
TheRealJimShady
  • 3,815
  • 4
  • 21
  • 40
273
votes
11 answers

How do you clear Apache Maven's cache?

Recently, Apache Maven seems to be having caching issues. Performing clean installs on our projects using Windows Vista or Windows 7 sometimes produce artifacts with the same data as a previous build even though the newer artifact's files should…
MetroidFan2002
  • 29,217
  • 16
  • 62
  • 80
271
votes
5 answers

How is "mvn clean install" different from "mvn install"?

What is the difference between mvn clean install and mvn install?
Leonid
  • 22,360
  • 25
  • 67
  • 91
263
votes
15 answers

Maven – Always download sources and javadocs

Is there a way I can configure maven to always download sources and javadocs? Specifying -DdownloadSources=true -DdownloadJavadocs=true everytime (which usually goes along with running mvn compile twice because I forgot the first time) becomes…
schmmd
  • 18,650
  • 16
  • 58
  • 102
263
votes
5 answers

How do you specify the Java compiler version in a pom.xml file?

I wrote some Maven code in Netbeans that has approximately more than 2000 lines. When I compile it on Netbeans, everything is fine, but if I want to run it on command line, I will get these errors: generics are not supported in -source 1.3 (use…
MTT
  • 5,113
  • 7
  • 35
  • 61