I've managed to get this working on my development environment using the Spring Loaded JVM agent. While I do develop Spring web applications, that project's description does mention that it is
usable on any bytecode that may run on a JVM
Using the following setup, I was able to get changes to publish automatically to an attached Tomcat instance (the usual Eclipse WTP method). I'm using Spring Tool Suite 3.7.3 based off Eclipse Mars.2 (4.5.2).
- Download the latest release JAR of Spring Loaded from their Github project. This has been tested with springloaded-1.2.5.RELEASE.jar.
- Setup a Tomcat Server in Eclipse as normal (tested with Tomcat 8.0.30)
- Open the Tomcat Server's configuration page in Eclipse (double-click on the server instance within the "Servers" tab).
- In the "Server Options" section, uncheck "Modules auto reload by default".
- Note: If you have web modules added to the server already, you may need to disable "Auto Reload" on them individually via the "Modules" tab (at bottom of configuration page window).
- In the "General Information" section, click "Open launch configuration"
- In the "Arguments" tab, add the following to the end of the "VM arguments":
-javaagent:/path/to/downloaded/springloaded-1.2.5.RELEASE.jar -noverify
- To enable JARs to be watched in addition to project's
.class
files, configure the -Dspringloaded=watchJars=
VM argument per this issue's comments.
Start the server and publish Dynamic Web Application projects to it as usual. Again, I was able to test this with Spring web applications. For example, modifying code, adding/subtracting methods, etc. in @Controller classes were applied nearly instantly after I save the file and Eclipse builds and publish the changed class. Lastly, the FAQ section of the Spring Loaded project did mention a few cases where things won't reload, so those would require a restart of the server/application. But those exceptions are much less frequent.
One more note: This does NOT work with the embedded Pivotal tc Server or VMware vFabric tc Server that comes with STS. For those servers, there is a "Enable Java Agent-based reloading (experimental)" option, but that uses the older 1.2.0 release of Spring Loaded, which did not work for me.