TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Apache Maven

Create a Simple Web application with Maven

Introduction

In this post, we will create a simple web application with Maven and IntelliJ IDEA. You can create a java web application using maven-archetype-webapp plugin. We can create using IDE tools as well as command-line console.

Steps to create:

Click Create New Project on the Welcome screen

or

Select File >> New >> Project.

You can select Maven tool and check the box create from the archetype

Select maven-archetype-webapp

 

Click on the Next button.

Project details

Enter groupid, artifactid and version details for the project and click on the Next button.

 

 

Optionally, you can also override the maven local and settings file configuration with custom ones.

 

In the next step, enter Project details like project name and location.

Click on the Finish button.

Once you hit on the finish button, the IDE would automatically create and build the project for you and download the dependencies. You can start adding functionality and web-pages on top of it.

 

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.testingdocs.demo.webapp</groupId>
 <artifactId>simple-webapp</artifactId>
 <packaging>war</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>simple-webapp Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <dependencies>
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>4.12</version>
 <scope>test</scope>
 </dependency>
 </dependencies>
 <build>
 <finalName>simple-webapp</finalName>
 </build>
</project>

 

Build, Deploy and Run

Once you are done with the step, execute maven goals under life cycle

View >> Tool Windows >> Maven Projects

Execute clean, compile, verify, and package goals.

Copy the war file created under the target folder and deploy it on the server.

Visit the URL: http://<<server>>:<<port>>/simple-webapp/

 

Using Command Line:

 

Related Posts

Apache Maven /

Download Maven on Windows 11

Apache Maven /

Fix Fatal Error compiling: Invalid target release in Maven Project

Apache Maven /

Create Maven Project from Archetype in NetBeans

Apache Maven /

Create a Maven Project skip archetype

Apache Maven /

Install Maven on Ubuntu Linux

‹ Maven Build Lifecycle› Maven Integration plugin for Eclipse IDE

Recent Posts

  • Scaler Academy – An Online Learning Platform
  • Difference between PHP and JavaScript?
  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com