Shortest code to start embedded Jetty server

前端 未结 5 1218
醉酒成梦
醉酒成梦 2021-01-30 15:30

I\'m writing some example code where an embedded Jetty server is started. The server must load exactly one servlet, send all requests to the servlet and listen on localhost:80

5条回答
  •  无人共我
    2021-01-30 15:59

    You could configure Jetty declaratively in a Spring applicationcontext.xml, e.g:

    http://roopindersingh.com/2008/12/10/spring-and-jetty-integration/

    then simply retrieve the server bean from the applicationcontext.xml and call start... I believe that makes it one line of code then... :)

    ((Server)appContext.getBean("jettyServer")).start();
    

    It's useful for integration tests involving Jetty.

提交回复
热议问题