22 November 2014

Generate webapp using maven archetype plugin

In this example describes how to create web app using maven archetype plugin.And here i used jetty server. First You have to install maven in your computer. http://mavenforu.blogspot.com/2013/09/maven-installation-guide.html in here i have explain how to install maven in windows.So then go to your workspace and type this command.

mvn archetype:generate -DgroupId=com.sajith.maven -DartifactId=MyFirstWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
GroupId and DartifactId can be change to your package name and project name.

Then Change the POM file and add the jetty maven plugin.Inside the Plugins notation add these plugin.
<plugin>
     <groupId>org.mortbay.jetty</groupId>
     <artifactId>maven-jetty-plugin</artifactId>
     <version>6.1.10</version>
     <configuration>
     <scanIntervalSeconds>10</scanIntervalSeconds>
     <connectors>
     <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
          <port>8080</port>
          <maxIdleTime>60000</maxIdleTime>
     </connector>
     </connectors>
     </configuration>
 </plugin>
Then Enter this command
mvn clean install
mvn jetty:run

No comments:

Post a Comment