I've got the following embedded Jetty setup:
ServletContextHandler topHandler = new ServletContextHandler(server, contextPath);
// Set path of static resources
topHandler.setBaseResource(...);
// Bind dynamic content to /api
RootResource rootResource = new RootResource();
FilterHolder restApiHandler = new FilterHolder(rootResource);
for (Entry<String, String> parameter : initParams.entrySet())
restApiHandler.setInitParameter(parameter.getKey(), parameter.getValue());
topHandler.addFilter(restApiHandler, "/api/*", EnumSet.allOf(DispatcherType.class));
// Bind static content to /
ServletHolder staticResourceHandler = topHandler.addServlet(DefaultServlet.class, "/");
server.start();
And I found documentation on Hot Deployment at https://www.eclipse.org/jetty/documentation/9.4.19.v20190610/hot-deployment.html but I don't understand how to put these together.
How do I get Jetty to reload servlets after their class files are reloaded so I don't have to restart the server every time I modify a Java file during development?