Eclipse Tomcat 未更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31248977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:44:09  来源:igfitidea点击:

Eclipse Tomcat not Updating

javaspringeclipsetomcathotdeploy

提问by Mauro M

I am developing an application with SpringMVC and Tomcat using Eclipse. The problem is: the server does not update the changes I am making.

我正在使用 Eclipse 开发带有 SpringMVC 和 Tomcat 的应用程序。问题是:服务器没有更新我所做的更改。

One example:

一个例子:

@RequestMapping(value = "test", method = RequestMethod.GET)
    public ModelAndView test(){

        ModelAndView mv = new ModelAndView("test");                 
        System.out.println("test");
        return mv;
    }

Every time I hit the mapped url, Eclipse prints test in my console. If I comment out the println, I get the same result.

每次我点击映射的 url 时,Eclipse 都会在我的控制台中打印测试。如果我注释掉println,我会得到相同的结果。

Attempts to fix the problem:

解决问题的尝试:

  • clean Tomcat directory
  • restart the server
  • close Eclipse
  • add/remove the project in the Server tab
  • delete the JSP the method is using
  • different browsers
  • 清理Tomcat目录
  • 重启服务器
  • 关闭日食
  • 在服务器选项卡中添加/删除项目
  • 删除该方法正在使用的 JSP
  • 不同的浏览器

All to no effect. It just looks like Tomcat is not updating any changes I make in the code.

都无济于事。看起来 Tomcat 没有更新我在代码中所做的任何更改。

回答by Arpit Aggarwal

To make Eclipse Tomcat update automatically or hot deploy you have to make certain changes in server configuration:

要使 Eclipse Tomcat 自动更新或热部署,您必须对服务器配置进行某些更改:

Below are the steps:

以下是步骤:

  1. Double clicks on the Tomcat Server, refer to "publishing"tab in the "Overview"view, make sure "Automatically publish when resources change"is selected. This should be the default option, to support “hot deploy”resources, for example : JSP, XML and properties files.

  2. In the Tomcat Plugin page, click on the "Modules"view, Select the Module then click on Edit button and make sure "Auto Reload"is "Disabled". Default is enabled.

  3. Start Project in DEBUGmode. Hot Deploy is supported in DEBUG mode only.

  1. 双击Tomcat Server,参考视图中的"publishing"选项卡"Overview",确保"Automatically publish when resources change"已选中。这应该是默认选项,以支持“hot deploy”资源,例如:JSP、XML 和属性文件。

  2. 在Tomcat插件页面,点击"Modules"查看,选择模块,然后单击编辑按钮,并确保"Auto Reload""Disabled"。默认启用。

  3. DEBUG模式启动项目。仅在调试模式下支持热部署。

回答by boly38

Two more things to check:

还有两件事要检查:

  • deploy directory: in the tomcat server UI and according to "deploy path" configuration, check that the output directory has read/write access (you could also remove it and try to publish again : check expected output resources/classes).
  • deployment assembly: in project properties menu; in the "deployment assembly" section, check that you are publishing all wanted resources. For example, in my case I download/generate some items from maven custom plugin phase and this resources are not published by default. I had to add some target subdirectories here...
  • 部署目录:在 tomcat 服务器 UI 中,根据“部署路径”配置,检查输出目录是否具有读/写访问权限(您也可以将其删除并再次尝试发布:检查预期的输出资源/类)。
  • 部署程序集:在项目属性菜单中;在“部署程序集”部分,检查您是否正在发布所有需要的资源。例如,在我的情况下,我从 maven 自定义插件阶段下载/生成一些项目,默认情况下不发布这些资源。我不得不在这里添加一些目标子目录...

回答by Marcelo Carvalho Nascimento

I had roughly the same problem and after tried it all with no success I gave up, created another fresh workspace and the problem was gone. Not the ideal solution but hey, it's an option.

我遇到了大致相同的问题,在尝试了所有但没有成功之后我放弃了,创建了另一个新的工作区,问题就消失了。不是理想的解决方案,但嘿,这是一个选择。