Reputation: 415
I have a web project in Eclipse which includes a Tomcat server. The Tomcat server is installed in Path C:\Program Data ... and my Workspace from Eclipse is in D:\Webproject.
Now if I have to edit my java servlet classes, I have to copy the class and JSP files from D:\Webproject to C:\Program Data\Tomcat\Webapps.... . This takes me a lot of time.
Is there any solution where the data is automatically deployed i.e. the edited classes and JSP are moved to my tomcat folder under C:.. ?
Upvotes: 6
Views: 12594
Reputation: 854
Eclipse can do all that work for you.
To add the Tomcat server in eclipse:
To deploy your project to the server:
You can then start/stop/debug/restart the server by right clicking on it.
When you modify a class/jsp it should be automatically deployed.
You can also force a republish of your project by right clicking on your project name after expanding the Tomcat server entry.
Double click on the Tomcat server entry if you need to modify the configuration of your server.
Upvotes: 6
Reputation: 12524
Ant is one possibility you have. Build your war-file and copy it automaticaly to your Tomcat directory. the tomcat will compile the sources via hot deploy. Here you get a nice documentation:
and the copy task:
Upvotes: 0
Reputation: 336
Ant is a little bit oldschool.
Try Maven: http://maven.apache.org/
(maven-deploy plugin)
Or gradle (imho better option): http://www.gradle.org/ (gradle install task)
You can also configure autodeploy in eclipse when you add your tomcat plugin to eclipse servers.
Upvotes: 0
Reputation: 62874
In order to avoid copying all the stuff manually, you can create a Context
for the Tomcat server, that points to the WEB-INF
folder of the application.
Go to `$TOMCAT_HOME/
Go to $TOMCAT_HOME/conf/server.xml
and add a context for where is the WEB-INF
of the project located. For example:
<Context path="/Webproject"
docBase="D:/Webproject/WEB-INF"
reloadable="true" />
What does this mean ?
http:// $tomcat-host:$tomcat-port>/Webproject
.Tomcat
will search for application to run under D:/Webproject/WEB-INF
.jsp
files or the web.xml
, the application will be reloaded automatically in Tomcat. That's what the reloadable="true"
stands for.Upvotes: 0
Reputation: 4123
You can consider configuring the Tomcat server into eclipse only, and map the corresponding webapp with that tomcat. This will give you the advantage that mostly when you edit the file it will get automatically deployed or you just have to republish the changes with a right click.
For a head-start:
http://www.eclipse.org/webtools/jst/components/ws/M4/tutorials/InstallTomcat.html
http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html
Upvotes: 0