Intoduction |
|
Eclipse web tools platform project supports default web project structure
of maven. The following test case imports a maven web project into the
eclipse workspace. Prerequisite of this test case is that maven should be
installed and configured on your system.
|
|
Installing and configuring Maven
|
|
Download maven from
http://maven.apache.org/
Installation instructions of maven can be found at
http://maven.apache.org/start/install.html
|
|
Structure of the Web Project
|
|  |
Steps |
 |
Setting up maven web project
|
|
-
Unzip
csrweb.zip
.
-
Create project.properties under the folder csrweb and add
maven.eclipse.projectnatures=org.eclipse.jst.j2ee.web.WebNature
-
Create the .j2ee file, set the webcontent folder to src/webapp
and context root to csrweb.
<?xml version="1.0"
encoding="UTF-8"?>
<j2eesettings version="600">
<moduleversion>23</moduleversion>
<webcontent>src/webapp</webcontent>
<context-root>csrweb</context-root>
</j2eesettings>
-
Go to the csrweb folder and execute "maven eclipse" from the
command prompt. This will generate .project and .classpath file.
- Launch eclipse
-
Go to "window-->preferences-->Java-->Build
Path-->Classpath Variables" and click "New". Enter MAVEN_REPO
in the name field and browse to the
$HOMEPATH/.maven/repository(C:\Documents and
Settings\Administrator\.maven\repository)
-
Import project in the Eclipse Workspace using Import->Existing
project into Workspace, and point to the csrweb directory.
-
Right click on the csrweb project and go to the properties. Go to
Java Build Path and change the "Default output folder" to be
csrweb/src/webapp/WEB-INF/classes. This is a temporary
restriction as wtp expects the output folder to be under
WEB-INF/classes.
Make sure there are no errors in the task bar.
|
 |
Exporting the web project
|
|
- Right click on the csrweb and select Export-->WAR file.
- Enter destination as c:\csrweb\csrweb.war.
-
Open the war file and make sure that the contents are exported
correctly.
|
 |
Running the web project on tomcat
|
|
-
Please refer to
running web project on tomcat
for running the project on tomcat server.
-
Invoke the HelloWorldServlet servlet by invoking
http://localhost:8080/csrweb/HelloWorldServlet
. Make sure it prints "Hello World" on the web browser.
|