Tomcat不会自动识别IntelliJ和Tomcat ....已更改的文件 [英] IntelliJ and Tomcat....changed files are not automatically recognized by Tomcat

查看:178
本文介绍了Tomcat不会自动识别IntelliJ和Tomcat ....已更改的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tomcat运行Intellij Ultimate并部署战争。一切都很好地部署到tomcat的webapp目录。

I am running Intellij Ultimate with Tomcat and deploying a war. Everything deploys fine to the webapp directory of tomcat.

当我更改像xhtml文件这样的文件时,有没有办法让tomcat自动获取该更改?到目前为止,我需要从intellij复制文件并将其复制到tomcat webapp目录中的目录。我知道某些文件需要重新编译,但xhtml不是其中之一。

When I change a file like an xhtml file, is there a way for tomcat to automatically pick up that change? As of right now I need to copy the file from intellij and copy it to the directory of where it lives in the tomcat webapp directory. I know there are certain files that will need a recompile, but xhtml's are not one of them.

推荐答案

如果不能您使用IntelliJ IDEA部署战争。但是,如果您部署爆炸战争可以。在IDEA中:

This cannot be done if you deploy a war with IntelliJ IDEA. However, it can be if you deploy an exploded war. In IDEA:


  1. 打开Tomcat运行/调试配置(运行>编辑配置

  2. 转到部署选项卡

  3. 在在服务器启动时部署部分中,删除(如果存在)工件 my-webapp -name:war

  4. 点击添加图标,选择'工件',然后选择 my-webapp-name:war explosion

  5. 单击确定(在选择要部署的工件对话框中)

  6. 仍然在运行/调试配置窗口中,选择服务器选项卡

  7. 在该选项卡的中间,将On frame Deactivation设置更改为Update resources或Update Classes and Resources


    • 更新资源:所有更改的资源(即除了类之外的所有应用程序组件)都将更新。

    • 更新类:和资源。所有更改的资源都将更新;更改的类将被重新编译。请注意,是否更新实际类取决于Web服务器的功能。如果我记得,Tomcat将重新加载html / xhtml和jsp文件,而不是JSP或Servlet使用的Servlet或类。您需要修改Tomcat以使用动态类加载器。

  1. open your Tomcat Run/Debug configuration (Run > Edit Configurations)
  2. Go to the "Deployment" tab
  3. In the "Deploy at Server Startup" section, remove (if present) the artifact my-webapp-name:war
  4. Click the add icon, select 'artifact' and then select my-webapp-name:war exploded
  5. Click OK (on the "Select Artifacts to Deploy" dialog)
  6. Still in the Run/Debug Configuration Window, select the "Server" tab
  7. In the middle of that tab, change the "On frame Deactivation" setting to either "Update resources" or "Update Classes and Resources"
    • Update resources: All changed resources (that is, all application components other than the classes) will be updated.
    • Update classes: and resources. All changed resources will be updated; changed classes will be recompiled. Note that whether the actual classes will be updated depends on the capabilities web server. If I recall, Tomcat will reload html/xhtml and jsp files, but not Servlets or classes that JSPs or Servlets use. You need to modified Tomcat to use a dynamic classloader for that.

  • 这确定了当你点击Update 图标(或 Ctrl + F10 )在运行窗口中。

  • 显示对话框确定每次点击更新图标时IDEA是否会提示您

  • This determined what happens when you hit the Update icon (or Ctrl+F10) in the Run window.
  • the "Show dialog" determines if IDEA prompts you each time you hit the update icon

现在任何时候你做一个更改时,IDEA将在IDEA的框架停用时重新部署更改的文件(即失去焦点)。它需要一两秒钟,你会在IDEA的较低状态栏中看到它。显然。你仍然需要刷新您的Web浏览器以便它获取新文件(当然,除非该页面具有像fetch一样的ajax的自动刷新)。

Now anytime you make a change, IDEA will redeploy the changed file(s) when IDEA's frame is deactivated (i.e. loses focus). It does take a second or two, You'll see it in the lower status bar in IDEA. Obviously. you'll still need to refresh your web browser so it fetches the new file (unless of course if the page has an auto refresh of ajax like fetch).

与Tomcat的良好组合是将On frame deactivation设置为Update Resources,将On'update操作设置为Redeploy或Restart Server。这允许通过帧停用来快速更新静态页面,并通过更新操作更新类。

A good combination with Tomcat is to set "On frame deactivation" to "Update Resources" and the "On 'update' action to either "Redeploy" or "Restart Server". That allows static pages to be quickly updated via frame deactivation, and class updated via the 'update' action.

名为ZeroTurnaround的公司销售 JRebel ,这是一个动态的类加载器解决方案。他们还有一个非常好的关于这个主题的五部分系列

A company named ZeroTurnaround sells JRebel which is a dynamic classloader solution. They also have a five part series on the subject that's very good.

这篇关于Tomcat不会自动识别IntelliJ和Tomcat ....已更改的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆