问题
We currently use MyEclipse with its built-in Maven4MyEclipse integration and its built-in J2EE server support, but want to convert over to regular eclipse (Helios specifically) to be able to use its 64-bit install on windows. (MyEclipse does not yet support 64-bit on Windows.)
So far I've got a working prototype of Helios eclipse using m2eclipse with the WTP plugin deploying our large web application to tomcat. Deployment is a little processor intensive, but it works and the app starts up.
What is critically different here is how the dependent projects are deployed. In our MyEclipse environment all of the dependent projects were deployed exploded out into the WEB-INF/classes folder, and so while the server was running, a change to a java class in the IDE would copy only the affected file(s) to the server's WEB-INF/classes and hot-swap the class into the JVM and... boom - live change to the server. GREAT for debugging.
In my helios conversion, however, all dependent projects get JARed and put into WEB-INF/lib. This has the advantage of actually looking like what our real maven-built production image looks like, but the development environment is severely disadvantaged by this in that the hot-swapping capability seems to be totally lost. Here, if I change a java class in a dependent project, m2eclipse will re-package the JAR, see that the deployed web application is out of sync, and republish the whole application. Not only is this a problem in that the entire web application has to cycle (something ours frankly doesn't do well given its size and huge initialization time), it is also a nasty delay in eclipse doing its republish. (For our application this takes about a minute or two.)
So my question is this: is there a way to get changes inside dependent projects to hot-swap to the running JVM and replace deployed files without this nasty republish penalty? I am assuming that this means deploying those class files to the WEB-INF/classes but don't know for sure that is (a) possible or (b) really necessary as part of this solution.
What are others doing to solve this? Is it solvable?
Thanks in advance!
回答1:
I think that you are looking for the solution described in Re: WTP Tomcat hot deploy with m2eclipse:
If you enable the "Serve Modules Without Publishing" option, then a special jar is added to the Tomcat server which allows the Tomcat support in WTP to control the "classpath" of the web application. Also, utility projects are not assembled in to jars. Instead, the Java output folder(s) of the utility projects are included in the "classpath" of the web application, effectively serving the class files directly. If you disable the auto-loading for the context, and run in debug mode, changes you make to classes can be hot-code-replaced so the context doesn't have to reload. I believe this will accomplish what you are looking for.
To do so:
- Go to the Server view
- Double-click your Tomcat server to open the server settings
- In Server Options, select the Serve modules without publishing option
- In Publishing, select the Never publish automatically option
来源:https://stackoverflow.com/questions/3405653/can-a-multi-module-m2eclipse-wtp-project-get-utility-modules-deployed-into-web-i