How to create Dynamic Web Maven project in STS(Spring Tool Suite) or Eclipse

What is Maven?
Maven is mostly used in the world.Inventor of maven was apache.It is apache based technology.Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation.

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:
  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features
Tools Needed:
  • Eclipse EE or STS(Spring Tool Suite)
  • Maven
  • JDK 1.9

Assumption:

You have setup Maven and Apache Tomcat Server successfully in your Eclipse or STS Environment.
Step-1:
          File -> New -> Project...


  • Select Maven Project and click Next
  • If you already created maven project then select Existing Maven project.
Step - 2:

Step - 3:

After clicking next there are lots of archetypes, if you want to choose other archetype, click on your archetype I select maven-archetype-webapp for web MVC project. 
Select the Maven archetype as maven-archetype-webapp and click on next

Step - 4:
Fill out below details and click Finish. This step creates Maven Project in your Eclipse or STS Environment.



Step - 5: 
If you see error “The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path index.jsp /CrunchifyMavenTutorial/src/main/webapp” then add below maven dependency.

 in  pom.xml

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>

OR add Apache Tomcat to your Targeted.


If you see an error like below(The superclass "javax.servlet.http.HttpServlet" index.jsp) image then do like this:
Go to Build Path -> Configure Properties.


check checkbox if it is unchecked and click on Apply and Close.
Note: If still project is not started then go to Build Path -> Deployment Assembly then add maven dependency click on apply and close.Now run a project.

Now it should look like this:


Now right click on your project and click on Run As -> Run on server


select your tomcat server and click next and then select your project.


select your project and click on finish.

If your OS is windows then it will ask permissions then click on allow access.

Output:




Share & leave us some comments on what you think about this topic or if you like to suggest something.






Comments

  1. Amazing article! I was confused about technology, but now got a clear view of the definition. Appreciate your hard work!
    Blockchain Training in Chennai
    Blockchain Training

    ReplyDelete

Post a Comment

Popular posts from this blog

Differentiate JDK, JRE and JVM

Class and Objects in Java