Expand Authors Top

If you have a few years of experience in the Java ecosystem and you’d like to share that with the community, have a look at our Contribution Guidelines.

Expanded Audience – Frontegg – Security (partner)
announcement - icon User management is very complex, when implemented properly. No surprise here.

Not having to roll all of that out manually, but instead integrating a mature, fully-fledged solution - yeah, that makes a lot of sense.
That's basically what Frontegg is - User Management for your application. It's focused on making your app scalable, secure and enjoyable for your users.
From signup to authentication, it supports simple scenarios all the way to complex and custom application logic.

Have a look:

>> Elegant User Management, Tailor-made for B2B SaaS

Generic Top

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:


1. Introduction

Apache Maven is one of the most popular build tools for Java projects. Apart from just decentralizing dependencies and repositories, promoting a uniform directory structure across projects is also one of its important aspects.

In this quick article, we'll explore the standard directory layout of a typical Maven project.

2. Directory Layout

A typical Maven project has a pom.xml file and a directory structure based on defined conventions:

        │   ├───java
        │   ├───resources
        │   ├───filters
        │   └───webapp
        │   ├───java
        │   ├───resources
        │   └───filters

The default directory layout can be overridden using project descriptors, but this is uncommon and discouraged.

Going ahead in this article, we'll uncover more details about each standard file and subdirectory.

3. The Root Directory

This directory serves as the root of every Maven project.

Let's take a closer look at the standard files and subdirectories that are typically found at root:

  • maven-project/pom.xml – defines dependencies and modules needed during the build lifecycle of a Maven project
  • maven-project/LICENSE.txt – licensing information of the project
  • maven-project/README.txt – summary of the project
  • maven-project/NOTICE.txt – information about third-party libraries used in the project
  • maven-project/src/main – contains source code and resources that become part of the artifact
  • maven-project/src/test – holds all the test code and resources
  • maven-project/src/it – usually reserved for integration tests used by the Maven Failsafe Plugin
  • maven-project/src/site – site documentation created using the Maven Site Plugin
  • maven-project/src/assembly – assembly configuration for packaging binaries

4. The src/main Directory

As the name indicates, src/main is the most important directory of a Maven project. Anything that is supposed to be part of an artifact, be it a jar or war, should be present here.

Its subdirectories are:

  • src/main/java – Java source code for the artifact
  • src/main/resources – configuration files and others such as i18n files, per-environment configuration files, and XML configurations
  • src/main/webapp – for web applications, contains resources like JavaScript, CSS, HTML files, view templates, and images
  • src/main/filters – contains files that inject values into configuration properties in the resources folder during the build phase

5. The src/test Directory

The directory src/test is the place where tests of each component in the application reside.

Note that none of these directories or files will become part of the artifact. Let's see its subdirectories:

  • src/test/java – Java source code for tests
  • src/test/resources – configuration files and others used by tests
  • src/test/filters – contains files that inject values into configuration properties in the resources folder during the test phase

6. Conclusion

In this article, we looked at the standard directory layout for an Apache Maven project.

Multiple examples of Maven project structures can be found in the GitHub project.

Generic bottom

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:

Maven footer banner
1 Comment
Inline Feedbacks
View all comments
Comments are closed on this article!