Reputation: 3002
My app configuration: Tomcat 8, Spring, Spring MVC, Hibernate.
In Eclipse I created Tomcat Server with my app added to resources. JSP, JS, CSS and JAVA classes hot deploy works just like that.
In IntelliJ I configured Tomcat 8 Server. In Deployment tab I added myapp:war exploded
.
I enabled On 'update' action
to Update classes and resources
, also i enabled On frame deactivation: Update classes and resources
.
JSP, JS, CSS hot swap works just like that. Java classes not.
I have also checked Settings > Build, exection, deployment > Compiler > Make project automatically
PS. I know I can use JRebel, but in Eclipse hot deploy works without JRebel. Why it does not work in IntelliJ?
Upvotes: 6
Views: 8078
Reputation: 6591
First of all, the name for the feature is not "hot deploy" but HotSwap. It is a feature of JVM and not of an IDE. IDEs just automate the process and trigger the HotSwap of the changed class automatically when there's a new version of the class available. HotSwap is limited only to the changes that can be made to a body of an existing method.
In IntelliJ, go to Settings->Debugger->HotSwap and check the settings:
Enable Reload classes in background checkbox and then you can choose the behaviour, should the IDE ask you about hotswapping the classes, hotswap silently, or never hotswap the classes.
You do have to compile manually. But, if the application is deployed from an "artifact", then "Make project automatically" works for the running application even though it says the opposite (Settings -> Compiler). The inconvenience though is that automatic compilation triggers with a delay, so it is not as instant as one would expect. Compiling manually is just as simple as pressing CTRL+S in Eclipse, just CTRL+F9/CMD+F9 to make the project (which is actually incremental) or CTRL+SHIFT+F9/CMD+SHIFT+F9 if you want to compile a single file.
I'd still recommend JRebel for improving the experience since it goes far beyond what HotSwap can do and it integrates with a large number of Java frameworks to eliminate redeploys. And yes, I'm biased - I work for ZeroTurnaround and I'm involved with JRebel development.
UPDATE:
The initial question was rather more about the automatic redeployment of the web app in Tomcat/IntelliJ In Run configuration, you can configure, what should be done for the 'Update' action:
The 'Update' action is invoked manually. CTRL+SHIFT+A/CMD+SHIFT+A, and search for 'Update':
So, redeployment is a rather "one-click" manual process in IntelliJ.
Upvotes: 10
Reputation: 15628
Did you notice the comment in IJ next to 'Make project automatically'?
only works while not running/debugging
To redeploy just do Ctrl+F9 (make) or Ctrl+Shift+F9 (make current file).
Upvotes: 0
Reputation: 46
In IJ you can set the eclipse compiler instead of the default javac compiler but still you will need to make manually.
Upvotes: 2