How to set Handler for embedded Jetty in Spring Boot?
<p>I am able to easily set handler for Jetty in a standard Java application like this:</p>

<pre><code>public class Main {
   public static void main(String[] args) throws Exception {
       Main main = new Main();
       main.start();
   }

   private void start() throws Exception {
       Server server = new Server(9999);
       server.setHandler(new Handler());
       server.start();
       server.join();
   }
}

class Handler extends AbstractHandler {
   @Override
   public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
       // do something
   }
}
</code></pre>

<p>How to set Handler similar way with Spring Boot with embedded Jetty? When I am trying with <code>EmbeddedServletContainerCustomizer</code> bean I am getting <code>missing ServletContext</code> exception.</p>

<pre><code>@Bean
    public EmbeddedServletContainerCustomizer customizer() throws MalformedURLException {
        return new EmbeddedServletContainerCustomizer() {

            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                if (container instanceof JettyEmbeddedServletContainerFactory) {
                    customizeJetty((JettyEmbeddedServletContainerFactory) container);
                }
            }

            private void customizeJetty(JettyEmbeddedServletContainerFactory jetty) {
                jetty.addServerCustomizers((JettyServerCustomizer) server -&gt; server.setHandler(myCustomHandler()));
            }
        };

    }
</code></pre>