简体   繁体   English

在 Jetty 的 webapp 中重新加载类

[英]Reload classes in a webapp in Jetty

Basically I'm searching for the equivalent in Jetty of the reloadable attribute in Tomcat:基本上,我正在 Jetty 中寻找 Tomcat 中可重新加载属性的等效项:

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

I want to configure my development environment such way I just compile a class, and the server detects the change and reloads automatically.我想配置我的开发环境,我只编译一个 class,服务器检测到更改并自动重新加载。

In Jetty the closest I've seen are these 2:在 Jetty 中,我见过的最接近的是这些 2:

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

but they just detect when a new app (war file or directory) is added/removed.但它们只是检测何时添加/删除新应用程序(war 文件或目录)。

Use the jetty-maven-plugin and one of its start or run goals flavors (there's a few choices, whole server, just a war, etc. so use the goal appropriate to what you want to accomplish)使用jetty-maven-plugin及其startrun目标风格之一(有几个选择,整个服务器,只是一场战争等,所以使用适合你想要完成的目标)

This will hot-reload your active project's webapp when it detects the kinds of changes you are wanting to trigger on.当它检测到您想要触发的更改类型时,这将热重新加载您活动项目的 web 应用程序。

But keep in mind that certain technology choices will "staple" the classloader and some classes, preventing them from being garbage collected, resulting in certain classes not being reloaded and a memory leak being introduced.但请记住,某些技术选择将“装订”类加载器和某些类,防止它们被垃圾收集,导致某些类不被重新加载并引入 memory 泄漏。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM