【问题标题】:updating jetty servlet 9.2.2 to 9.3.8将码头 servlet 9.2.2 更新到 9.3.8
【发布时间】:2016-08-19 00:34:50
【问题描述】:

我正在尝试将 jetty 服务器和 servlet 从版本 9.2.2 更新到版本 9.3.8 更新我的 pom.xml 文件后,我得到一些错误,如 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>

这是我的 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");
}

和错误

[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

【问题讨论】:

    标签: maven servlets jetty jetty-9


    【解决方案1】:

    您的依赖项中有错字。

    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId> <!-- not plural! -->
        <version>9.3.8.v20160314</version>
    </dependency>
    

    【讨论】:

    • 非常感谢。实际上我是从码头网站mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets/… 复制的
    • 那不是码头的网站。 eclipse jetty 项目建议在 mvnrepository.com 上使用search.maven.org(这是非常不准确和误导性的)
    • 哦,好吧!当我用谷歌搜索时,第一个网站是 mvnrepository.com。谢谢你的信息
    • 哇,我想我的 bazel 规则错了很长时间,太混乱了:(
    猜你喜欢
    • 1970-01-01
    • 2017-12-25
    • 2016-02-17
    • 2014-09-19
    • 2017-11-22
    • 2016-02-05
    • 2020-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多