Recently, received many emails for mkyong.com tutorials, about how to deploy the project to Tomcat, build the project with Maven, and also how to import it into Eclipse IDE.
At the end of the tutorial, the entire Eclipse’s project and source code are zipped and provide user to download.
In this demonstration, we are using this “Struts 2 hello world example” tutorial, to show you how to download the project, build and import it into Eclipse IDE.
Hope this guide will help others to use the mkyong tutorial more easily. For those familiar with Maven and Eclipse, you can skip this guide.
To use the tutorial, make sure you have following tools installed, and have some basic understanding about it, especially Maven.
- Installed Tomcat
- Installed Maven
- Installed Eclipse
2. Download Project
Scroll down to the end of the article, click on the download link.
3. Project Structure
Extract the downloaded zip file.
In this example, extract the zip files to following folder :
See following extracted project structure, a standard Eclipse + Maven project structure.
To reduce the zip file size, i deleted all the classes in “target” folder, you need to build it to make it works, see next step.
4. Maven Build
Issue following Maven command to build the project :
mvn eclipse:eclipse -Dwtpversion=2.0
In this example, Windows, command prompt, build like this.
C:\Users\mkyong\Downloads\Struts2Example>mvn eclipse:eclipse -Dwtpversion=2.0
This tell Maven to download the entire project’s dependencies declared in
pom.xml, and configure the deployment path in Eclipse properly… it make everything ready for developing and deployment.
5. Import into Eclipse
Everything is ready now, import the project into Eclipse IDE.
In Eclipse menu, select “File“, “Import…“, “General” –> “Existing Project into Workspace“, select the project file path and import it.
Your project structure should look like this :
6. Deploy to Tomcat
In Eclipse IDE, create a Tomcat instance, add the project and start it.
In Eclipse, review the console tab, make sure no error messages displayed, otherwise… send me an email :)
Done. Happy coding