In this tutorial, we provide a step-by-step guide on how to create a web project using Maven in Eclipse.
Open eclipse, then select File -> New -> Maven Project.
New Project Maven" />
In the next screen, select the workspace of the project and keep the other options as default then click “Next”:
In the following screen, select “maven-archetype-webapp” then click “Next”:
In the final screen, fill the mandatory fields as the following:
Eclipse now generates a dynamic web project called “SimpleWebProject”, in case you face this error inside index.jsp:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path index.jsp
then just add the following dependency to pom.xml:
javax.servlet javax.servlet-api 3.1.0
In order to compile your project with Java 8, add the following property to pom.xml:
1.8 1.8
then right click project -> Maven -> Update Project
Here we go, the structure of the generated project looks like the following:
Finally deploy the web application on Tomcat, if you haven’t setup Tomcat in your eclipse, then follow this guide.
After the deployment, you would be able to access index.jsp through the following url:
In this tutorial, we provide a step-by-step guide on how to create a web project using Maven in Eclipse.
If you're interested in learning more about the basics of Java, coding, and software development, check out our Coding Essentials Guidebook for Developers, where we cover the essential languages, concepts, and tools that you'll need to become a professional developer.
Thanks and happy coding! We hope you enjoyed this article. If you have any questions or comments, feel free to reach out to jacob@initialcommit.io.