java 在开发环境中的 tomcat 中重新加载 webapp 的简单快捷的方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1800784/
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-10-29 18:02:29  来源:igfitidea点击:

What's an easy, quick way to reload a webapp in tomcat in dev environment?

javatomcat

提问by Marplesoft

I'm running Tomcat 6 on Windows. I've got the "Monitor Tomcat" system tray icon which allows me to start and shutdown Tomcat, but is there another little tool that allows me to easily reload my web app when I've changed the class files? I know the "manager" app that comes with Tomcat has a redeploy option, but just wondering if there's a native app that would do this a bit quicker and nicer?

我在 Windows 上运行 Tomcat 6。我有“Monitor Tomcat”系统托盘图标,它允许我启动和关闭 Tomcat,但是有没有另一个小工具可以让我在更改类文件时轻松重新加载我的 Web 应用程序?我知道 Tomcat 附带的“管理器”应用程序有一个重新部署选项,但只是想知道是否有一个本地应用程序可以更快更好地执行此操作?

回答by Carl Smotricz

Assuming you've already set reloadable=true, you can toucheither the war file in the webapps directory, or a monitored file such as WEB-INF/web.xml in the exploded application directory. This will update the time stamp and make the app look new, so it will be reloaded.

假设你已经设置好了reloadable=true,可以touch是webapps目录下的war文件,也可以是展开的应用目录下的WEB-INF/web.xml等监控文件。这将更新时间戳并使应用程序看起来很新,因此它将被重新加载。

At our company, we run our Web app servers in dev mode all the time just to facilitate this. To hell with the recommendation, we know better than to run our app on 99% load so we can't spare a few cycles.

在我们公司,我们一直在开发模式下运行我们的 Web 应用程序服务器只是为了促进这一点。见鬼去建议,我们知道最好不要在 99% 的负载下运行我们的应用程序,所以我们不能节省几个周期。

回答by Pascal Thivent

Just add a reloadable=trueattribute to the Context. Quoting the documentation:

只需添加一个reloadable=true属性到Context. 引用文档

Set to trueif you want Catalina to monitor classes in /WEB-INF/classes/and /WEB-INF/libfor changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Managerweb application, however, to trigger reloads of deployed applications on demand.

设置为true,如果你想卡塔利娜监测类/WEB-INF/classes//WEB-INF/lib更改,并自动如果检测到变化重新加载Web应用程序。此功能在应用程序开发过程中非常有用,但它需要大量的运行时开销,不推荐用于已部署的生产应用程序。这就是为什么此属性的默认设置是false. 但是,您可以使用ManagerWeb 应用程序按需触发已部署应用程序的重新加载。