Integrating tomcat and eclipse as a hot-deploy env

2019-01-01 06:18发布

I would like to setup eclipse and tomcat in an integrated fashion such that changes to my JSPs and servlets(if possible) are reflected immedietely without requiring a deployment.

Ok, this is one of those questions that has plenty of answers all across the internet but they all seem different. (use Sysdeo plugin, use JBOss plugin, do stuff with an outdated Eclipse, use MyEclipse instead etc.) and I couldn't find 1 definitive resource to refer to. So for my benefit, what is the simplest and most recommended procedure to set this up ?

This assumes I have eclipse and tomcat running independently. I actually have managed to integrate them in a non-hot deploy fashion using instructions here : http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html

Eclipse version Version: 3.4.2 (Ganymede) Tomcat v6.0.20

16条回答
步步皆殇っ
2楼-- · 2019-01-01 06:50

Change your workspace in Eclipse to \tomcat\webapps Since it is just for your work, this should work fine. Whatever changes you make in Eclipse is in the same directory tomcat looks for applications to deploy

查看更多
何处买醉
3楼-- · 2019-01-01 06:50

What works for me here is:

context.xml like this:

<Context path="/myapp" docBase="myapp" debug="5"
    reloadable="false" antiResourceLocking="false" antiJARLocking="true">
<!-- this because i´m using Spring 3.1 with Tomcat -->
    <Loader     loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" />

</Context>

Then, on Servers tab in Eclipse, on "Modules" tab, I disabled the "Auto Reload" to all the modules being deployed.

Also let the default config to let the auto publishing.

And is using Maven with WTP, don´t forget to leave the contents of src/main/resources in, because Eclipse insists to exclude the contents of this folder of the final build.

Only with all this I got full (VM) classes hot-deploy with resources hot-deploy!!!

查看更多
梦该遗忘
4楼-- · 2019-01-01 06:51

In your development environment, just point your Tomcat server to look for JSPs in whatever directory you're developing them in. As soon as you save the file, you'll be able to see the changes then.

查看更多
若你有天会懂
5楼-- · 2019-01-01 06:53

Simply let eclipse write the class files directly to the $TOMCAT/webapps/MyWebApp/WEB_INF/classes directory. Then, configure apache-tomcat to check if the class files have been updated, and reload them if they have.

To configure tomcat to auto-reload a class when it changes, you need to

edit $TOMCAT/conf/context.xml and set :

<Context reloadable="true"> 

You may also have to edit and reload your webapps/$YourWebApp/web.xml file and include :

<web-app reloadable="true">

I can't remember if both changes are needed but that's how I configured my tomcat-6.0.18 to auto-reload.

查看更多
ら面具成の殇う
6楼-- · 2019-01-01 06:54

In case, you're in hurry:

  1. check "never publish automatically" in tomcat(other container) in eclipse.
  2. start tomcat(other container) in debug mode.

voila! :)

查看更多
无与为乐者.
7楼-- · 2019-01-01 06:59

I've found a simplest way: use of symbolic links: I think this is the fastest way because there is no synchronization at all: tomcat directory and your project directory will be the same directory all the time.

Tomcat will periodically detect the changes and redeploy your application.

There is also a way to debug your application, so I humbly think is a good solution.

I've documented my solution here, for anyone interested.

查看更多
登录 后发表回答