Apache Maven 3 Cookbook
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Java Development with <strong>Maven</strong><br />
Then we will look at a host of popular enterprise frameworks including Spring Framework,<br />
Hibernate ORM Framework, and JBoss Seam Framework. These frameworks are highly<br />
popular, and with their popularity growing by the day among Agile teams, they are quickly<br />
replacing the cumbersome J2EE development paradigm of the late 90s and early 2000s.<br />
They represent the future of Web and Enterprise Java Development. The recipes in this<br />
chapter will focus on specific plugins for these frameworks and the implementation of<br />
these frameworks in your <strong>Maven</strong> projects.<br />
Building a web application<br />
This recipe will see us creating a simple web application with a <strong>Maven</strong> Archetype plugin. The<br />
web application will:<br />
ff<br />
ff<br />
ff<br />
ff<br />
Run in an embedded web application server (Jetty)<br />
Have some dependencies added<br />
Contain a simple servlet<br />
Have a WAR file generated<br />
Our goal here is for you to be able to start using <strong>Maven</strong> to accelerate web application<br />
development.<br />
Getting ready<br />
We start off with the concept of a (POWA) Plain Old Web Application, that is, a web<br />
application project consisting of one servlet and one Java Server Page (JSP). The archetype<br />
template that will be used to generate a POWA is org.sonatype.mavenbook.simpleweb.<br />
How to do it...<br />
Start the command-line terminal and execute the following generate command:<br />
$ mvn archetype:generate -DarchetypeArtifactId=maven-archetypewebapp<br />
-DartifactId=testWebApp -DgroupId=net.srirangan.packt.maven<br />
-Dversion=1.0-SNAPSHOT -Dpackage=net.srirangan.packt.maven<br />
You should get the following output. Notice that you will get a prompt asking for the package.<br />
[INFO] Scanning for projects...<br />
[INFO] -------------------------------------------------------<br />
[INFO] Building <strong>Maven</strong> Stub Project (No POM) 1 ------------------------<br />
-------------------------------<br />
[INFO]<br />
[INFO] >>> maven-archetype-plugin:2.0-alpha-5:generate (default-cli) @<br />
standalone-pom >>><br />
96