Maven Directory Structure

Jakob Jenkov
Last update: 2015-10-08

The Maven directory structure is a standard directory structure which Maven expects to build a project. You do not have to follow the Maven directory structure, but it is much easier if you do, and it also makes it easier for other developers to understand your project directory structure.

Standard Maven Directory Structure

The standard Maven directory structure looks like this:

  - pom.xml

  - .mvn
    - jvm.config

  - src
    - main
      - java
      - resources
    - test
      - java
      - resources

  - target

The above directories are the most commonly used directories of a Maven project. There are a few more directories with special purposes which have been left out because they are not often used.

The myprojectdir is the root dir for your project. You are free to choose whatever directory name you want for your project.

The pom.xml file is the Maven POM file (Project Object Model). The POM file is described in more detail here: Maven POM file .

The .mvn directory is a directory where you can put some Maven configuration files. One of these Maven configuration files is the jvm.config file which can be used to configure the Java VM that is used by Maven to build your project. Some of the settings you can set in this file are the Maven memory limits.

The src directory is the root directory for both application and test source code.

The application source code goes into src/main/java . Any resource files (e.g. property files) needed by your application goes into the src/main/resources directories. The resource files will be available for loading via the classpath.

The test source code goes into src/test/java . Any resource files (e.g. property files) needed by your test code goes into src/test/resources. The resource files will be available for loading via the classpath.

The target directory contains all the final products that are the result of Maven building your project. The target directory also contain any temporary and intermediate files needed by Maven when building your application.

You can learn more about the Maven directory structure from Maven's own documentation here: Introduction to the Maven Standard Directory Layout (although it seems this page is not entirely up-to-date).

Jakob Jenkov

Featured Videos

Java ForkJoinPool

P2P Networks Introduction


Java Persistence
Close TOC
All Tutorial Trails
All Trails
Table of contents (TOC) for this tutorial trail
Trail TOC
Table of contents (TOC) for this tutorial
Page TOC
Previous tutorial in this tutorial trail
Next tutorial in this tutorial trail