Creating java web project using maven in eclipse with Apache Tomcat
Maven is a very popular build tools used in most of the Java Application for building the project.Maven
handles all the jar dependency,project packaging,maintaining the application version,clean,build etc.
In this post, we are going to share how to create simple maven web application.
Software and Technologies Used:
Eclipse Mars
Apache Tomcat 8.0.33
Apache Maven 3.3.9
JDK 1.8
1- Install Maven and Eclipse
2- Go to the folder where you want to create the project and execute below command to create maven application.
mvn archetype:generate -DgroupId=com.javainstance -DartifactId=sampleWeb -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
where groupId is the package name.
artifactId is sampleweb
3- Go to project folder which has pom.xml file and execute below command to convert it to eclipse project.
mvn eclipse:eclipse
4- Once build success then import the project as existing maven project and add the Tomcat server.
5- It may be required to correct the build path by removing and adding proper folder structure for missing build path entries.
Check the build path entries and make it as follows
5-Right click on the project got to properties and verify the project facets and web.xml schema also as per Dynamic Web project version.
In this sample 3.0 version is used for which below is the schema.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
6-Add below maven compiler plugin to pom.xml to make it compatible for JDK 1.8 and run application as maven install.
<build>
<finalName>sampleWeb</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
7-Run project on server
You may be interested in Deploying Maven Application on Tomcat.
Give you suggestion in comments.If you like the post Share with your friends on social network.
handles all the jar dependency,project packaging,maintaining the application version,clean,build etc.
In this post, we are going to share how to create simple maven web application.
Software and Technologies Used:
Eclipse Mars
Apache Tomcat 8.0.33
Apache Maven 3.3.9
JDK 1.8
1- Install Maven and Eclipse
2- Go to the folder where you want to create the project and execute below command to create maven application.
mvn archetype:generate -DgroupId=com.javainstance -DartifactId=sampleWeb -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
artifactId is sampleweb
3- Go to project folder which has pom.xml file and execute below command to convert it to eclipse project.
mvn eclipse:eclipse
4- Once build success then import the project as existing maven project and add the Tomcat server.
5- It may be required to correct the build path by removing and adding proper folder structure for missing build path entries.
Check the build path entries and make it as follows
5-Right click on the project got to properties and verify the project facets and web.xml schema also as per Dynamic Web project version.
In this sample 3.0 version is used for which below is the schema.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
6-Add below maven compiler plugin to pom.xml to make it compatible for JDK 1.8 and run application as maven install.
<build>
<finalName>sampleWeb</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
7-Run project on server
You may be interested in Deploying Maven Application on Tomcat.
Give you suggestion in comments.If you like the post Share with your friends on social network.
Creating java web project using maven in eclipse with Apache Tomcat
Reviewed by JavaInstance
on
11:28:00 AM
Rating:
Reviewed by JavaInstance
on
11:28:00 AM
Rating:





Good tutorial :)
ReplyDelete