0
votes

I want to embed jetty in one of my spring mvc application. I followed the tutorial http://examples.javacodegeeks.com/enterprise-java/jetty/jetty-tutorial-beginners/ (scroll down to embedded jetty part i.e 2.0).

I followed and understood the tutorial but it seems to be working for servlets only whereas in my application I'm having controller methods.

Server server = new Server(7070);
        ServletContextHandler handler = new ServletContextHandler(server, "/example");
            handler.addServlet(ExampleServlet.class, "/");
            server.start();

This code seems to add only a servlet (ExampleServlet.class) in embedded jetty but I want to make it work for my spring mvc application where I'm using @RequestMapping etc for URL information. The question is how to add those controllers in the embedded context handlers. Please let me know what all changes I need to do to embed jetty in my spring mvc application and following most of the part of this tutorial http://examples.javacodegeeks.com/enterprise-java/jetty/jetty-tutorial-beginners/ (scroll down to embedded jetty part)

1

1 Answers

0
votes

Manual embedding is obsolete; use Spring Boot instead, which handles all of this for you. Boot offers out-of-the-box starters for Tomcat, Jetty, or Undertow.