Exploded War deployment with IntelliJ Idea, Maven, Tomcat and JRebel

Hung Tran picture Hung Tran · Jan 23, 2013 · Viewed 17.2k times · Source

I'm developing a web-based application with IntelliJ Idea 12, Maven, JRebel and Tomcat. In order to take advantage of JRebel, automatically reloading changes to Spring beans, I used the exploded war deployment provided by Intellij below

IntelliJ exploded war deployment

Due to a Maven module, IntelliJ exactly followed Maven's convention to compile Java files into the output folder (target/classes) which is DIFFERENT to the exploded webapp directoy (target/spring-mvc-showcase/webapp/web-inf/classes). As a result, Tomcat and JRebel can't reload changes of these new classes.

At the moment, I temporarily configured IntelliJ's output folder pointed to the folder WEB-INF/classes so that changes could be reloaded. As I don't want to break Maven conventions, could anyone tell me a more elegant solution?

target (Maven generated artifact directory)
  |
   -- classes (compiled)
  |
   -- spring-mvc-showcase (exploded webapp directory)
           |
            -- WEB-INF
                 |
                   -- classes

Answer

ag0rex picture ag0rex · Jan 23, 2013

After you've configured it properly, when you're starting Tomcat, you should see something like this:

[2013-01-23 15:39:12] JRebel: Directory '/home/xxx/workspace/xxx/trunk/target/classes' will be monitored for changes.
[2013-01-23 15:39:12] JRebel: Directory '/home/xxx/workspace/xxx/trunk/src/main/webapp' will be monitored for changes.

Then what I do is each time I change something, instead of running maven package, I perform "Make project" (in IDEA), /target/classes folder gets updated and configuration will reload its classes automatically.