🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In a previous article, we have discussed how to create a simple maven project in eclipse. In this article, we will show you how to create a web project or application using maven in Eclipse IDE.
Let me list out what are tools and technologies that I have used to create a web project or application using maven in Eclipse IDE.
Now, let's test this web project by adding simple Servlet and deploy on tomcat server.
To execute the about maven command in Eclipse IDE, Click on Run menu → Run Configuration.. to create a new configuration.
In Run Configuration Wizard, double-click on Maven Build and provide the configuration information (Name, Base directory and Goals) as shown in the below image.
Now click on the Run and monitor the output in console.
That's all. I hope you understood the flow of creating a web project using Maven in Eclipse. Do comment if you need any help or issues.
Let me list out what are tools and technologies that I have used to create a web project or application using maven in Eclipse IDE.
Tools and technologies used
- IDE - Eclipse Neon
- JDK - 1.8
- Maven - 3.5.3
- Apache Tomcat - 8.5
- Servlet API - 3.1.0
Let’s start step by step to create a web project using Maven in Eclipse IDE.
Step-1
- Open Eclipse
- Click on File -> New -> Maven Project
Step-2
- Don't select a simple project as shown in below diagram
- Select default Workspace location
- Click on Next
Step-3
Select the Maven archetype as maven-archetype-webapp and click on next.Step-4
Provide GroupId, ArtifactId, package and click on finish.
- GroupId: net.javaguides.maven-web-project
- Artifact Id: MavenWebApp
- package: net.javaguides.maven_web_project
Step-5
Now, let's test this web project by adding simple Servlet and deploy on tomcat server.
Step-6
Open pom.xml file and add servlet API dependency and maven compiler plugin as:<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>net.javaguides.maven-web-project</groupId> <artifactId>MavenWebApp</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>MavenWebApp 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> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>MavenWebApp</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
Step-7
Now create a SimpleServlet class under net.javaguides.mavenwebapp package and write the following code in it.package net.javaguides.mavenwebapp; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class SimpleServlet */ @WebServlet("/hello") public class SimpleServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); resp.getWriter().write("Hello World! Maven Web Project Example."); } }
Step-8
Let's Build the project using the following maven command.- mvn clean installTo execute the about maven command in Eclipse IDE, Click on Run menu → Run Configuration.. to create a new configuration.
In Run Configuration Wizard, double-click on Maven Build and provide the configuration information (Name, Base directory and Goals) as shown in the below image.
Now click on the Run and monitor the output in console.
Step-9
Let's deploy our web project into tomcat. Let's first configure tomcat server in Eclipse IDE via server section. Once deployment is a success then Open a browser and type http://localhost:8080/hello URL in address bar.My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
🆕 High-Demand
80–90% OFF
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
🆕 High-Demand
80–90% OFF
ChatGPT + Generative AI + Prompt Engineering for Beginners
🚀 Trending Now
80–90% OFF
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
🌟 Top Rated
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
🌟 Top Rated
80–90% OFF
Testing Spring Boot Application with JUnit and Mockito
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Master Spring Data JPA with Hibernate
🔥 Bestseller
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
🎓 Student Favorite
80–90% OFF
Available in Udemy for Business
Available in Udemy for Business

Comments
Post a Comment
Leave Comment