idea 中Update resources和Update classes and resources、Redeploy的区别和应用场景

官方文档链接:https://www.jetbrains.com/help/idea/updating-applications-on-application-servers.html#update_options

Application update options

The update options are different depending on:

  • the artifact format, i.e. on whether the application artifact is exploded (unpacked) or packed (e.g. WAR, EAR)
  • the run/debug configuration type, i.e. on whether the run/debug configuration is local or remote (see Local and remote run configurations)
Option Description Available for
Update resources All changed resources are updated (HTML, JSP, JavaScript, CSS and image files). Exploded artifacts in local configurations
Update classes and resources Changed resources are updated; changed Java classes (EJBs, servlets, etc.) are recompiled.

In the debug mode, the updated classes are hot-swapped. In the run mode, IntelliJ IDEA just updates the changed classes in the output folder. Whether such classes are actually reloaded in the running application, depends on the capabilities of the runtime being used.

Exploded artifacts in local configurations
Hot swap classes Changed classes are recompiled and reloaded at runtime. This option works only in the debug mode. Packed artifacts in local configurations; exploded and packed artifacts in remote configurations
Redeploy The application artifact is rebuilt and redeployed. The operation may be time-consuming. Exploded and packed artifacts in local and remote configurations
Restart server The server is restarted. The application artifact is rebuilt and redeployed. The operation may be very time-consuming. Exploded and packed artifacts in local configurations

 

再来看看Idea--Tomcate配置中的On Upate Action 与 On Frame Deactivation

这两个选项的设置,依赖于 项目的部署方式 是 exploded

1、on update action

首先来看 on update action 相关的解释,从字面上理解 就是 手工触发 update 动作的时候 做什么:技术分享  技术分享   update resources ---- 更新静态的资源,比如html,js,css等 运行模式和调试模式都是立即生效。 update classes and resources ---- 更新java,jsp和静态资源( 1. java 修改后,会被编译成.class 然后覆盖到target/kao文件夹下,IDE调试模式的情况下,立即生效。IDE运行模式下,不立即生效,需要redeployed才可生效。 2. jsp修改后,再次被访问的时候,会自动更新,重新编译成.java---->.class 保存在tomcat的work目录下。由于是访问时才检测是否修改,是否需要重新编译,所以 IDE 运行模式 和 IDE调试模式下,都是立即生效。刷新下页面就可); redeployed ----- 重新部署,发布到tomcat里,不重启tomcat,而是把原来的删掉,然后重新发布; restart server ----- 重启tomcat ------------------------------------------------------------------------------------------------------------------------

2、on frame deactivation 

再来看on frame deactivation ,意思是 IDE 失活时 做什么,就是说 IDE 失去焦点时 做什么。  技术分享   Do nothing --------- 什么都不做update resources ---- 更新静态的资源,比如html,js,css等 运行模式和调试模式都是立即生效。 update classes and resources ---- 更新java,jsp和静态资源 同上。   验证上方的结论看如下GIF:  静态资源不用测试了,测试 On Update Action 的 (update classes and resources)在debug模式 与 运行模式下的差别。 1.运行模式下,jsp是 update classes and resources 是立即生效的,但是.java文件修改后 并不会立即生效。 技术分享    2.debug调试模式下,jsp和java文件修改 都会立即生效: 技术分享
3.测试on frame deactivation 即IDE 失去焦点时自动做一些事, 我们测试 让其update classes and resources ,以调试模式为例,运行模式除了java 修改不会自动生效,其它一致;技术分享

 四、总结:

总结,这样设置是最佳的选择: 技术分享   因为On frame deactivation IDE失去焦点的情况下 自动触发,而开发过程中 可能需要查询资料 或 与人聊天 或干其它事,IDE需要不停的失去焦点。每次失去焦点就自动触发 update ,CPU一下子 费很多,电脑瞬间变慢,所以没有必要这样,设置为Do nothing 最好,官方也默认的是 Do nothing。 On Update action ------- update classes and resources ----- 运行模式下(jsp 立即生效,java 需要redeploy才可生效) On Update action ------- update classes and resources ----- 调试模式下(java、jsp 都立即生效)   =================完结了!!!!!!!!这块非常灵活,这篇博客研究了一天 才写出来,很多时候 不知道 如何组织 如何写,才能更加 简单明了。  

 

转自:https://blog.csdn.net/qq_26489457/article/details/81224553

          https://www.cnblogs.com/zhangguangju/p/7027904.html