I have 2 Maven projects in Eclipse workspace, A and B.
Project B is a web project that depends on A. I have also made these projects child modules of a parent to enable transitive dependencies.
Now my approaches to deploy the web project B is
- Compile and build jar for Project A, say A.jar. Copy A.jar and its dependencies to webapp/WEB-INF/lib of project B.
- Compile B and build war for project B, say B.war
- Set the tomcat(eclipse embedded tomcat) docBase to the folder of
B.war.
This works fine. But because Tomcat is not using my source code, it does not see my local code changes immediately.
My question is, how do I make tomcat use my source code? and how can I configure Tomcat & Eclipse such that in a local running web app, whenever I make code changes in Project A & B (B dependes on A), the changes take effects immediately(hot swap)?
Thank you in advance.
You can’t make Tomcat run source code. It has to be compiled first. The best you can do is make it notice when new versions of your classes get compiled. As your project A is bundled into B as a JAR, the only option I’m aware of to get Tomcat to hot-swap new code in for project A is JRebel. It’s not a free product, but there’s a free trial so you can see how awesome it is, and if this is a persistent problem for you, it’s probably worth the money. Also, your local Java User Group can give away two JRebel licenses each month. It might be worth attending.