Questions tagged [maven-3]

Apache Maven is a tool for project management and build automation. This tag is for questions relating to Maven version 3.x. For non version-specific questions, please use the [maven] tag.

Apache Maven is a tool for project management and build automation. Maven relies on a pom.xml file that describes the project instead of defining a set of tasks, like Ant does.

A basic pom.xml looks like:

<project>
  <!-- model version is always 4.0.0 for Maven 2 and Maven 3 POMs -->
  <modelVersion>4.0.0</modelVersion>

  <!-- A project is identified by its groupId, artifactId and version -->
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0</version>

  <!-- Dependencies -->
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <!--
           The scope allows you to limit the usage of this dependency.
           In this case, this library will only be used for tests purposes.
      -->
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Many plugins exist, and offer more functionalities to the tool.


For non version-specific questions, please use , for the older maven versions 2.x or the legacy 1.x use or , 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.

5199 questions
95
votes
17 answers

Maven 3 and JUnit 4 compilation problem: package org.junit does not exist

I am trying to build a simple Java project with Maven. In my pom-file I declare JUnit 4.8.2 as the only dependency. Still Maven insists on using JUnit version 3.8.1. How do I fix it? The problem manifests itself in a compilation failure: "package…
Are Husby
  • 2,089
  • 2
  • 16
  • 14
93
votes
1 answer

Can not set the final jar name with maven-assembly-plugin

This is how I configured maven-assembly-plugin org.apache.maven.plugins maven-assembly-plugin 2.4 myapp
Truong Ha
  • 10,468
  • 11
  • 40
  • 45
93
votes
1 answer

How do I add a project as a dependency of another project?

There are two independent projects (myWarProject and MyEjbProject). So when I build the myWarProject I need to install the MyEjbProject in to the local repository, so then I can define in the myWarProject as dependency and package the myWarProject…
kds
  • 28,155
  • 9
  • 38
  • 55
90
votes
4 answers

Warning on using project.parent.version as the version of a module in Maven 3

In maven multi-module projects where I want each of the modules to always keep the same version as the parent, I've typically done something like the following in the module's pom.xml: com.groupId
whaley
  • 16,075
  • 10
  • 57
  • 68
90
votes
5 answers

maven error: package org.junit does not exist

I'm trying to create the javadoc with maven and it fails. It also fails when doing the verify. mvn verify I get the following error: (...) [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : …
theme
  • 1,097
  • 2
  • 9
  • 13
89
votes
6 answers

How do you deal with maven-3 timestamped snapshots efficiently?

Now that maven-3 did drop support for the false for snapshot artefacts it seems that you really need to use timestamped SNAPSHOTS. Especially m2eclipse, which does use maven 3 internally seems to be affected with it,…
mglauche
  • 3,344
  • 4
  • 28
  • 31
89
votes
15 answers

Finding the root directory of a multi module Maven reactor project

Is there an easy way to find the root of a multi-module Maven project, like Gradle's rootDir? Background: I want to use the maven-dependency-plugin to copy artifacts from all sub-modules of my multi-module project to a directory that is relative to…
Christoffer Hammarström
  • 27,242
  • 4
  • 49
  • 58
88
votes
7 answers

NoClassDefFoundError on Maven dependency

My first use of Maven and I'm stuck with dependencies. I created a Maven project with Eclipse and added dependencies, and it was working without problems. But when I try to run it via command line: $ mvn package # successfully completes $ java -cp…
utdemir
  • 26,532
  • 10
  • 62
  • 81
79
votes
6 answers

Maven spring boot run debug with arguments

Usually I'm running my Spring Boot application with command: mvn spring-boot:run -Drun.arguments=--server.port=9090 \ -Dpath.to.config.dir=/var/data/my/config/dir I want to set custom port to debug, so I can connect from eclipse. When I add…
wbk
  • 1,310
  • 2
  • 11
  • 19
78
votes
3 answers

Send maven output to file

On Windows 7, I am trying to send the output of a maven-3 command to a text file. I call the command from the root of the project I am trying to analyze. The command is: mvn dependency:tree -Dverbose -Dincludes=commons-collections…
rapt
  • 11,810
  • 35
  • 103
  • 145
77
votes
6 answers

How do I prevent Maven from downloading artifacts every time?

I’m using Maven 3.1.1. In one of my projects, I reference another one of my projects … org.mainco.subco myprojectA
Dave
  • 15,639
  • 133
  • 442
  • 830
77
votes
4 answers

Correct way to declare multiple scope for Maven dependency?

I have a dependency that I want to use in test scope (so that it is in the classpath when I am running unit tests), and in runtime scope (so that I can contain that in WAR/EAR/other packaging for deployment, but not affecting transitive dependency…
Adrian Shum
  • 38,812
  • 10
  • 83
  • 131
76
votes
7 answers

What is the Maven way for automatic project versions when doing continuous delivery?

I have a web application where we deploy to production whenever a feature is ready, sometimes that can be a couple of times a day, sometimes it can be a couple of weeks between releases. Currently, we don't increment our version numbers for our…
ams
  • 60,316
  • 68
  • 200
  • 288
73
votes
10 answers

Intellij Idea Maven 'cannot reconnect' error

Maybe you can help me I got a strange apache maven's problem, when opening my project at Intellij Idea 13. When projects was open I have no libraries at External Libraries section. And at all pom.xml files from diff's modules I see error "Cannot…
MeetJoeBlack
  • 2,804
  • 9
  • 40
  • 66
72
votes
10 answers

IntelliJ new project - maven archetype list empty

When creating IntelliJ → New Project → Maven, the archetype list is blank and does not populate no matter how long the amount of time elapsed. The "Loading archetype list..." continues but does not appear to do much. Any suggestions? Info from mvn…
DanCat
  • 2,504
  • 2
  • 19
  • 26