将码头servlet 9.2.2更新到9.3.8

Sen*_*han 1 servlets jetty maven jetty-9

在更新pom.xml文件后,我试图将Jetty服务器和Servlet从9.2.2版本更新到9.3.8版本,但遇到找不到ServletContextHandler和ServletHolder之类的错误!

这是我的pom.xml

<dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.3.8.v20160314</version>
    </dependency>

    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlets</artifactId>
        <version>9.3.8.v20160314</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的JettyServer类

public static void start() throws Exception
{
    Server server = new Server(Configuration.getInstance().getPortServer());

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    ServletHolder h = new ServletHolder(new HttpServletDispatcher());
    h.setInitParameter("javax.ws.rs.Application", "de.jettyserver.Services");
    context.addServlet(h, "/*");

    server.setHandler(context);

    server.start();
    server.join();

    LOGGER.debug("JettyServer started");
}
Run Code Online (Sandbox Code Playgroud)

和错误

[ERROR] /C:/..../jettyserver/JettyServer.java:[4,33] package org.eclipse.jetty.servlet does not exist

[ERROR]/C:/../jettyserver/JettyServer.java:[5,33] package org.eclipse.jetty.servlet does not exist
[ERROR] /C:/../jettyserver/JettyServer.java:[27,17] cannot find symbol symbol:   class ServletContextHandler location: class de.tuberlin.snet.sonic.jettyserver.JettyServer

    [ERROR] /C:/../jettyserver/JettyServer.java:[27,53] cannot find symbol symbol:   class ServletContextHandler location: class de.tuberlin.snet.sonic.jettyserver.JettyServer
[ERROR] /C:/../jettyserver/JettyServer.java:[27,75] cannot find symbol symbol:   variable ServletContextHandler location: class de.tuberlin.snet.sonic.jettyserver.JettyServer
Run Code Online (Sandbox Code Playgroud)

Joa*_*elt 5

您的依赖项有错别字。

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlet</artifactId> <!-- not plural! -->
    <version>9.3.8.v20160314</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)