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
208
votes
10 answers

What is "pom" packaging in maven?

I was given a maven project to compile and get deployed on a tomcat server. I have never used maven before today, but I have been googling quite a bit. It seems like the top level pom.xml files in this project have the packaging type set as…
Derek
  • 11,715
  • 32
  • 127
  • 228
207
votes
8 answers

Maven check for updated dependencies in repository

Is there a Maven plugin that allows you to check if there are newer versions of dependencies available in the repository? Say, you are using dependency X with version 1.2. Now a new version of X is released with version 1.3. I'd like to know, based…
froethen
  • 2,083
  • 2
  • 13
  • 5
203
votes
6 answers

Skip a submodule during a Maven build

We have a need to be able to skip a submodule in certain environments. The module in question contains integration tests and takes half an hour to run. So we want to include it when building on the CI server, but when developers build locally (and…
denishaskin
  • 3,305
  • 3
  • 24
  • 33
202
votes
2 answers

Maven "Module" vs "Project" (Eclipse, m2eclipse plugin)

I'm a beginner at Maven and I've played with it from a command line point of view a little, so now I was trying to use it in Eclipse; I installed the m2eclipse plugin to do so. But I'm stumped from the very beginning! Apparently I've missed a bit of…
Ricket
  • 33,368
  • 30
  • 112
  • 143
202
votes
22 answers

Fatal error compiling: invalid target release: 1.8 -> [Help 1]

Similar problem like one posted on invalid target release: 1.7 but after following the blog my problem is still unresolved. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hm_app: Fatal…
rvd
  • 2,214
  • 3
  • 13
  • 14
196
votes
31 answers

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved

org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for…
Curt
  • 2,944
  • 6
  • 29
  • 34
195
votes
4 answers

Disable a Maven plugin defined in a parent POM

I am using a parent POM that defines a plugin that I do not want to be run in a child POM. How can I disable the plugin in the child pom completely? Constraint: I cannot change the parent POM itself.
tobiasbayer
  • 10,269
  • 4
  • 46
  • 64
192
votes
7 answers

Prevent unit tests but allow integration tests in Maven

I've a Maven build in which I use the SureFire plugin to run some unit tests, and the FailSafe plugin to run some integration tests. I would like a way to run just the FailSafe plugin's tests. It's not a good solution for me to add different…
190
votes
3 answers

java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment

I am somewhat new to coding and am trying to use the Lombok plugin to automatically create Getters/Setters e.t.c. for my fields of a specific class. In doing so I get greeted with the following error: The error: java: java.lang.IllegalAccessError:…
Dainank
  • 2,142
  • 2
  • 7
  • 14
189
votes
13 answers

Force re-download of release dependency using Maven

I'm working on a project with dependency X. X, in turn, depends on Y. I used to explicitly include Y in my project's pom. However, it was not used and to make things cleaner, I instead added it to X's pom as a dependency. X is marked as a release…
volni
  • 5,196
  • 8
  • 38
  • 44
189
votes
22 answers

How to disable maven blocking external HTTP repositories?

Maven blocks external HTTP repositories by default since version 3.8.1 (see https://maven.apache.org/docs/3.8.1/release-notes.html) Is there a way to disable that or to exempt a repository from this rule?
Sebu
  • 4,671
  • 5
  • 16
  • 29
189
votes
17 answers

Why is no one using make for Java?

Just about every Java project that I've seen either uses Maven or Ant. They are fine tools and I think just about any project can use them. But what ever happened to make? It's used for a variety of non-Java projects and can easily handle Java. …
User1
  • 39,458
  • 69
  • 187
  • 265
189
votes
7 answers

How to find/remove unused dependencies in Gradle

I wanted to find unused dependencies in my project. Is there a feature for this in Gradle, like in Maven?
Alexander Bezrodniy
  • 8,474
  • 7
  • 22
  • 24
189
votes
16 answers

Intelli J IDEA takes forever to update indices

Is it normal for Intelli J to take a lot of time (almost 12 hours) to update indices for a project? I just installed Intelli J on my machine and imported a rather large Maven project (13k+ files). I understand that the project is large but I let my…
0x56794E
  • 20,883
  • 13
  • 42
  • 58
187
votes
8 answers

Could not autowire field:RestTemplate in Spring boot application

I am getting below exception while running Spring Boot application during start up: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of autowired dependencies failed; nested…
Khuzi
  • 2,792
  • 3
  • 15
  • 26