加速 Eclipse Web 浏览器中的代码更改?

发布于 2024-11-17 20:17:59 字数 334 浏览 1 评论 0原文

我正在 Eclipse 中使用 Vaadin 框架开发一个应用程序。我正在使用 Tomcat v6.0 servlet 并在 Eclipse Web 浏览器中运行该应用程序。我一直遇到的一个问题是,当我测试应用程序时,最近的更改会显示在浏览器中。

无论我重新启动 Tomcat、清理所有已发布资源并重新启动 Eclipse Web 浏览器多少次,更改仍然不会生效。这些更改似乎是随机生效的,其中时间是最大的因素,这在开发时非常令人沮丧...

所以我的问题是是否有其他人注意到这个问题并且有任何解决方案的想法,如果有配置我可以这样做,或者如果我在重新启动时错过了阻止更改生效的步骤..?

任何帮助将不胜感激!

I'm developing an application using the Vaadin framework in Eclipse. I'm using the Tomcat v6.0 servlet and run the application in the Eclipse Web Browser. A problem I've been having though is to have recent changes show in the browser when I test the application.

No matter how many times I restart Tomcat, clean all published resources and restart the Eclipse Web Browser the changes still won't take effect. The changes seem to take effect randomly where time is the biggest factor, which is of great frustration when developing...

So my question is if anyone else has noticed this problem and have any ideas of how to solve it, if there is a configuration I can do or if I'm missing a step in the restart which blocks the changes from taking effect..?

Any help would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光与爱终年不遇 2024-11-24 20:17:59

在 Vaadin 中,大部分代码在服务器中运行并包含在普通 Java 文件中。资源/类更改分为三个级别:

  1. 运行时“热代码替换”。如果在调试模式下运行 Tomcat,则可以发布某些 Java 类更改,而无需重新部署 Web 应用程序。但是,如果 Tomcat 配置为“自动发布”(检查 Eclipse 中的服务器设置),则只要类发生更改,就会自动完成重新部署,这会导致完全上下文重新加载和会话序列化(请参阅#2)。可以使用 JRebel 等工具来增强热代码替换。

  2. Web 应用程序部署。这本质上是向服务器部署一个新的 war 文件。导致先前版本被取消部署并部署所有类和资源的新版本。有时,服务器工作目录中剩余一些资源或类未重新加载,在这种情况下需要重新启动服务器(#3)。

  3. 服务器重新启动。这使得整个 JVM 重新加载,所有类和 Web 应用程序也都重新加载。仍然需要单独清理工作目录以确保重新加载所有内容。

除此之外,还有 Vaadin 的客户端部分(本质上是用 GWT 编译的 JavaScript),它被 Tomcat 视为静态资源。如果您修改客户端 Java 代码,GWT 将用于重新编译 JavaScript。部署应该只是文件复制。浏览器会缓存生成的 HTML/JS 文件,但 GWT 包含避免这种情况的机制。

您应该首先尝试更改自动发布的服务器设置,看看是否有帮助。另外,我注意到不同的 Tomcat 版本的行为有所不同。这很不幸,但您唯一能做的就是尝试找到适合您的版本/设置。

In Vaadin most of the code runs in the server and is contained in normal Java files. There are three levels of resource/class changes:

  1. The runtime "hot code replacement". If running Tomcat in debug mode some Java class changes can be published without redeploying the web application. However, if the Tomcat is configured to "auto publish" (check your server settings in Eclipse), the redeployment is automatically done whenever classes change and this causes full context reload and sessions serialization (see #2) . Hot code replacement can be enhanced using tools like JRebel.

  2. Web application deployment. This is essentially deploying a new war file to the server. Causes the previous version to be undeployed and deploys the new version of all classes and resources. Sometimes there are some resources left in the servers work directory or classes are not reloaded, in which case the server restart (#3) is needed.

  3. Server restart. This makes the whole JVM to reload and all the classes and web applications are also reloaded. Still cleaning the work directory separately is needed to make sure everything is reloaded.

In addition to this there is the client-side part of Vaadin (essentially a JavaScript compiled with GWT), which is treated as a static resource by Tomcat. If you modify the client-side Java code the GWT is used to recompile the JavaScript. Deployment should be simply file copying. The browsers cache the generated HTML/JS files, but GWT includes mechanism to avoid this.

You should first try to change the server settings for automatic publishing and see if that helps. Also, I've noticed that different Tomcat version behave differently. This is unfortunate, but the only thing you can do is to try to find the versions/set-up that works for you.

只想待在家 2024-11-24 20:17:59

只是为了确保:您已在 URL 中添加 ?restartApplication 以强制应用程序在页面重新加载时重新启动,不是吗?

Just to make sure: you have been adding ?restartApplication in the URL to force application to restart on page reload, haven't you?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文