简体   繁体   English

Eclipse与IntelliJ热部署

[英]Eclipse vs IntelliJ Hot Deploy

My app configuration: Tomcat 8, Spring, Spring MVC, Hibernate. 我的app配置:Tomcat 8,Spring,Spring MVC,Hibernate。

In Eclipse I created Tomcat Server with my app added to resources. 在Eclipse中,我创建了Tomcat Server,并将我的应用程序添加到资源中。 JSP, JS, CSS and JAVA classes hot deploy works just like that. JSP,JS,CSS和JAVA类热部署就像这样工作。

In IntelliJ I configured Tomcat 8 Server. 在IntelliJ中,我配置了Tomcat 8 Server。 In Deployment tab I added myapp:war exploded . 在部署选项卡中,我添加了myapp:war exploded I enabled On 'update' action to Update classes and resources , also i enabled On frame deactivation: Update classes and resources . 我启用了On 'update' actionUpdate classes and resources ,同时我启用了On frame deactivation: Update classes and resources JSP, JS, CSS hot swap works just like that. JSP,JS,CSS热插拔就是这样的。 Java classes not. Java类没有。

I have also checked Settings > Build, exection, deployment > Compiler > Make project automatically 我还检查了Settings > Build, exection, deployment > Compiler > Make project automatically

PS. PS。 I know I can use JRebel, but in Eclipse hot deploy works without JRebel. 我知道我可以使用JRebel,但在Eclipse热部署中没有JRebel。 Why it does not work in IntelliJ? 为什么它在IntelliJ中不起作用?

First of all, the name for the feature is not "hot deploy" but HotSwap. 首先,该功能的名称不是“热部署”,而是HotSwap。 It is a feature of JVM and not of an IDE. 它是JVM的一个功能,而不是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. IDE只是自动执行该过程,并在有可用的新版本时自动触发已更改类的HotSwap。 HotSwap is limited only to the changes that can be made to a body of an existing method. HotSwap仅限于可以对现有方法的主体进行的更改。

In IntelliJ, go to Settings->Debugger->HotSwap and check the settings: 在IntelliJ中,转到Settings-> Debugger-> HotSwap并检查设置:

HotSwap设置

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. 在后台启用重新加载类复选框,然后您可以选择行为,如果IDE要求您热插拔类,静默热交换或永不热切换类。

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. 手动编译就像在Eclipse中按CTRL + S一样简单,只需按CTRL + F9 / CMD + F9即可生成项目(实际上是增量)或CTRL + SHIFT + F9 / CMD + SHIFT + F9如果要编译单个文件。

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. 我仍然建议JRebel改进体验,因为它远远超出HotSwap的功能,并且它与大量的Java框架集成以消除重新部署。 And yes, I'm biased - I work for ZeroTurnaround and I'm involved with JRebel development. 是的,我有偏见 - 我为ZeroTurnaround工作,我参与了JRebel开发。

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: 最初的问题更多是关于在Tomcat / IntelliJ In Run配置中自动重新部署Web应用程序,您可以配置“更新”操作应该做什么:

更新动作

The 'Update' action is invoked manually. 手动调用“更新”操作。 CTRL + SHIFT + A / CMD + SHIFT + A , and search for 'Update': CTRL + SHIFT + A / CMD + SHIFT + A ,并搜索“更新”:

在此输入图像描述

So, redeployment is a rather "one-click" manual process in IntelliJ. 因此,重新部署是IntelliJ中相当“一键”的手动过程。

在IJ中,您可以设置eclipse编译器而不是默认的javac编译器,但仍然需要手动进行。

Did you notice the comment in IJ next to 'Make project automatically'? 您是否注意到“自动生成项目”旁边的IJ中的注释?

only works while not running/debugging 仅在未运行/调试时有效

To redeploy just do Ctrl + F9 (make) or Ctrl + Shift + F9 (make current file). 要重新部署,只需执行Ctrl + F9 (制作)或Ctrl + Shift + F9 (制作当前文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM