tomcat的autoDeploy是否可以重新部署解压后的目录

Is it possible for tomcat's autoDeploy to redeploy unpacked directory

我知道如果将新的 .WAR 文件复制到 webapps 目录,运行 Tomcat 可以重新部署网络应用程序。

然而,在开发模式下,仅部署已编译的 类 会更快,并且根据 tomcat 中的文档:https://tomcat.apache.org/tomcat-9.0-doc/appdev/deployment.html,可以将 Web 应用程序部署到Tomcat 只需将已编译的 类 和资源复制到 Tomcat 的 webapps 目录。

我的问题是,如果新编译的 类 在 webapps 目录中发生更改,Tomcat 是否可以自动部署?

您要查找的是上下文元素上的 reloadable 属性(参见 context container). This will regularly scan all the files in your web application and cause a reload if something changed. This is very useful during development, but very heavy in production (cf. )。

如果 WAR 文件或 XML 部署描述符更改:

This flag value indicates if Tomcat should check periodically for new or updated web applications while Tomcat is running. If true, Tomcat periodically checks the appBase and xmlBase directories and deploys any new web applications or context XML descriptors found. Updated web applications or context XML descriptors will trigger a reload of the web application.

(强调我的)

如果 reloadable 属性不适合您的需要,还有第三种解决方案:通过使用 WatchedResources 您可以仅监视某些应用程序文件并在它们更改时重新加载。