Issue
I am new to IntelliJ, and I created a run configuration to debug my web application using intellij.
What I did are:
- ran my application on intellij debug mode, and saw server start up successfully, html file got rendered correctly.
- modified a java file.
- modified a html file.
- saved them.
- clicked somewhere outside the intellij window to trigger hotswap.
- I saw message pop up saying only 1 file updated (It was the java file).
The issue I found is:
- The html never got updated.
What I noticed are:
- the java file was recompiled and "hotswapped" successfully.
- the html file was not "hotswapped":
- The page in browser did not reflect the change I made.
- html did not update even I manually refresh the web page in browser.
- if i modify only the html file in IntelliJ, pop up alwasy would always say "loaded classes are up to date. Nothing to upload".
- but I verified html source is successfully changed, and the html file being deployed to the exploded war directory was also successfully changed.
- when I clicked the "redeploy" button, then I could see the html get updated.
- I have also tried adding cachingAllowed="false" to tomcat context.xml file, but no luck.
- the html file was not "hotswapped":
My questions are:
- How to enable hotswap in IntelliJ with tomcat9?
(Did I miss anything?)
- What is the difference between "hotswap" and "redeploy"?
Thanks.
IntelliJ version: Ultimate 2018.1
Tomcat version: apache-tomcat-9.0.7
Solution
- answer
I found the answer over here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000004090-Updating-HTML-and-Resources-without-restarting-application-server-Tomcat-8-Thymeleaf-3-Sparkjava-?page=1#community_comment_360000203964
Reason as Ulisses Silva pointed out: the Thymeleaf's implementation of the TemplateResolver has a "cacheable" attribute with "true" as default attribute.
Solution
set the "cacheable" attribute to false as follows to your TemplateResolver definition:
<property name="cacheable" value="false" />
Answered By - zaozaoer