简体   繁体   中英

Reload classes in a webapp in Jetty

Basically I'm searching for the equivalent in Jetty of the reloadable attribute in Tomcat:

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.

In Jetty the closest I've seen are these 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

but they just detect when a new app (war file or directory) is added/removed.

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)

This will hot-reload your active project's webapp when it detects the kinds of changes you are wanting to trigger on.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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