在 Jetty 的网络应用程序中重新加载 类

Reload classes in a webapp in Jetty

基本上我在 Tomcat:

中搜索可重新加载属性的 Jetty 等价物

https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes

我想配置我的开发环境,我只编译了一个 class,服务器会检测到更改并自动重新加载。

在 Jetty,我见过最接近的是这两个:

https://www.eclipse.org/jetty/documentation/current/hot-deployment.html https://www.eclipse.org/jetty/documentation/current/deployment-architecture.html#default-web-app-provider

但他们只是检测新应用程序(war 文件或目录)何时为 added/removed。

使用 jetty-maven-plugin 和其中一个 startrun 目标风格(有几个选择,整个服务器,只有一个 war,等等。所以使用适合你想要完成的目标)

这将在检测到您想要触发的更改类型时热重载您的活动项目的 webapp。

但请记住,某些技术选择会 "staple" 类加载器和一些 类,防止它们被垃圾收集,导致某些 类 不被重新加载和内存正在引入泄漏。

参见:https://www.eclipse.org/jetty/documentation/current/preventing-memory-leaks.html