renanleandrof
renanleandrof

Reputation: 7007

IntelliJ IDEA: Auto code update on tomcat7:run

On eclipse, when you execute a Maven RUN with: tomcat7:run on your project, if you change some classes, you don't need to re-run your application in order to check the changes. I think is "hot-code swap" or something like that.

Is it possible to do that on IntelliJ?

Upvotes: 1

Views: 1320

Answers (2)

rwpreece
rwpreece

Reputation: 5

Here's what I found to work with the Maven tomcat7:run plugin in IntelliJ IDEA 2017.3 using a Run/Debug Configuration.

After you create the Run/Debug Configuration and configure Java Hot Swap in your IntelliJ Settings, you MUST run this configuration in DEBUG mode.

While the Tomcat server is running, you can make code changes and recompile them with ctrl+shift+F9 and IntelliJ IDEA will pop-up a message telling you that "some classes have changed" and asking "would you like to deploy the updates/changes?" (due to Settings > Ask). Answer Yes and IntelliJ will display a status telling you if it succeeded, in which case you can send your POST/GET request again to test your changes, OR, if it failed to deploy the changes, in which case you'll need to Stop Tomcat and Start it again.

Success or failure to deploy your changes depends on whether or not your changes are allowed by Java's Hot Swap feature. Refer to your JDK docs.

Here are the images for my IntelliJ IDEA Settings and my Run/Debug Configuration:

Java Hot Swap Settings

Run/Debug Configuration

NOTE: You can add options to the Before Launch section to do additional steps you might need such as copying additional "resource" files to your "target/classes" folder. For example, you can call a script, with an External Tool option, that you've written to copy additional "resource" files to your "target/classes" folder. IntelliJ's docs explain how to use the Before Launch feature.

Upvotes: 0

elporfirio
elporfirio

Reputation: 336

yeah you have 4 options:

First press Ctrl + F10

you will see:

  • Update Classes
  • Update Resources and Clases
  • Redeploy
  • Restart Server

The second is the answer. More info here:

http://www.jetbrains.com/idea/webhelp/updating-applications-running-on-application-servers.html

EDIT 2018: IntelliJ IDEA 2017.3.3

Upvotes: 2

Related Questions