Friday, April 8, 2011

Folder Structure for a Standard Maven 3 Web App

Taken from Chapter 3 - Basic Application Setup

Spring Persistence with Hibernate


Though you can define a custom directory structure and modify your Maven settings or graft Maven onto a legacy project with a directory structure that's already defined, your best bet is to stick with the basic folder structure that Maven expects. That will ensure proper interoperability with all of the plugins and tools that are available.

To build a basic art gallery application, start by making a folder called gallery:

mkdir gallery

Within the gallery folder, create the folders that are customary for a Java application:

mkdir gallery/src mkdir gallery/src/main mkdir gallery/src/main/java mkdir gallery/src/main/resources mkdir gallery/src/main/resources/META-INF 

For web applications, we need a webapp and WEB-INF folder:

mkdir gallery/src/main/webapp mkdir gallery/src/main/webapp/WEB-INF 

We also need to create the folders that are required for unit testing our application:

mkdir gallery/src/test mkdir gallery/src/test/java mkdir gallery/src/test/resources 

And finally, create the two folders where Spring configuration files are ordinarily placed:

mkdir gallery/src/main/webapp/WEB-INF/spring

mkdir gallery/src/main/resources/META-INF/spring
Note

You can also have maven automatically generate your project's structure by using Maven's archetype feature. Maven archetypes are like project templates that can be used to streamline the creation of a maven project, including setting up your directory structure and a baseline pom.xml file.

1 comment:

mayank said...

nice thinking......keep it up.