How to Create the java web-application with command prompt using maven
To create a simple java project using maven, you need to open the command prompt and run the archetype: generate command of the mvn tool.
The syntax to generate the project architecture is given below:
The example to generate the project architecture is given below:
After type the above command 3 files automatically created by maven those are:
Here is my web.xml file
To run the application follow the below steps
Step1: First go to the project folder and open the command prompt.
Step2: To clean the project type the following command:mvn clean
Step3: To Compile the project type the following command: mvn package,mvn install
Go to the target folder war file automatically generated while packaging or install command. deploy into a tomcat server.
The syntax to generate the project architecture is given below:
mvn archetype:generate -DgroupId=groupId -DartifactId=projectName-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
The example to generate the project architecture is given below:
mvn archetype:generate -DgroupId=com.quickdevops -DartifactId=samplewebapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
After type the above command 3 files automatically created by maven those are:
- Index.jsp
- pom.xml
- web.xml
Here is my Index.jsp
<html> <body> <h2>Hello World!</h2> </body> </html>
Here is my pom.xml file
<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.Quickdevops</groupId> <artifactId>SampleWebApplication</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>CubeGeneratorWeb 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>CubeGeneratorWeb</finalName> </build> </project>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> </web-app>
To run the application follow the below steps
Step1: First go to the project folder and open the command prompt.
Step2: To clean the project type the following command:mvn clean
Step3: To Compile the project type the following command: mvn package,mvn install
Go to the target folder war file automatically generated while packaging or install command. deploy into a tomcat server.
0 Response to "How to Create the java web-application with command prompt using maven"
Post a Comment