What is the ideal way to configure Tomcat to serve directly from my project\'s directory inside of my workspace? (related)
I want my static web resources
I do not want to come off as promoting anything, but Netbeans IDE supports all of these out of the box, no plugins necessary, it also includes a pre configured tomcat;
It supports copying static resources on save, so there is no need to rebuild your whole application:
As for any java changes, if you are in debug mode there is an Apply Code Changes
button, which will rebuild and deploy your changed files (assuming no structural changes were made)
or alternatively use JRebel (for deploying changed java files) which has excellent features
This depends on whether you object to taking some action, like hitting Publish, or if you object to the copy happening even if it's transparent. Static content like CSS, HTML or JavaScript should get automatically deployed (i.e. copied) when you save, assuming you have "Automatically publish when resources change" under "Publishing" selected in Tomcat's server configuration. You should refresh in your browser and see the changes, barring some browser caching.
If you truly want Tomcat to look directly at your project's static files, then run Tomcat with nothing deployed (unless you have Java classes to deploy in the same project) and edit the server.xml
file under Servers
> Apache Tomcat v7.0 at localhost-config
and add some Context
elements under Host
like this:
<Context docBase="C:\path\workspace\project\WebContent\css" path="/project/css" reloadable="true" />
It's unclear if you are using the Eclipse WTP approach with Tomcat or some custom deployment strategy.
I switched away from running Tomcat in Eclipse because of unreliable re-publishing of changed JARs. I'm now using Jetty via the Run Jetty Run Eclipse plug-in (available in the Eclipse Marketplace). This appears to run from the workspace and does not do the republish-to-a-deployment-directory approach that Eclipse uses with Tomcat.
You don't get dynamic code reload with this option, but you can add that feature back with JRebel.
Going further left-field, switch to a JVM language/framework that supports seeing your changes instantly without re-publishing/restarting such as: