Book Image

Mastering Apache Maven 3

Book Image

Mastering Apache Maven 3

Overview of this book

Table of Contents (16 chapters)
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Java EE web applications with the archetype plugin


If you want to start with a Java EE web application, you can simply use the maven-archetype-webapp archetype to generate the Maven project skeleton, which is shown as follows:

$ mvn archetype:generate -B
                   -DgroupId=com.packt.samples
                   -DartifactId=my-webapp 
                   -Dpackage=com.packt.samples.webapp 
                   -Dversion=1.0.0  
                   -DarchetypeGroupId=org.apache.maven.archetypes  
                   -DarchetypeArtifactId=maven-archetype-webapp 
                   -DarchetypeVersion=1.0

The preceding command will produce the following directory structure. One issue here is that it does not have the java directory just after src/main. If you want to add any Java code, you need to make sure that you first create an src/main/java directory and create your Java package under it. Otherwise, with the default configuration settings, Maven won't pick your classes for compilation...