go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Create a web application project
 
Subject: Create a web application project
Author: Alex_Raj
In response to: Let's run it!
Posted on: 03/29/2012 12:37:33 AM

mvn archetype:generate -DgroupId=com.mycompany -DartifactId=MyWebProject
 -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false


Output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
 maven-archetype-webapp:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: packageName, Value: com.mycompany
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: artifactId, Value: MyWebProject
[INFO] Parameter: basedir, Value: C:\HelloWorld\Maven\MyFirstWebProject
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\HelloWorld\Maven\MyFi
rstWebProject\MyWebProject
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.892s
[INFO] Finished at: Wed Mar 28 22:18:14 PDT 2012
[INFO] Final Memory: 9M/122M
[INFO] ------------------------------------------------------------------------




The generated Maven WebApp project is of the following structure:
 [+] -- MyWebProject
     [-] -- pom.xml
     [+] -- src
         [+] -- main
             [+] -- resources
             [+] -- webapp
                 [-] -- index.jsp
                 [+] -- WEB-INF
                     [-] -- web.xml


The pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>MyWebProject</artifactId>

  <packaging>war</packaging>

  <version>1.0-SNAPSHOT</version>

  <name>MyWebProject Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>MyWebProject</finalName>
  </build>

</project>



The building tool
mvn package

is going to wrap everything into war file.

 

> On 03/26/2012 12:24:41 AM Alex_Raj wrote:

You may test the newly compiled and packaged JAR with the following command:
java -cp ./target/MyProject-1.0-SNAPSHOT.jar com.mycompany.App

Which will print:
Hello World!






References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.