2016-04-25 36 views
0

我試圖更新jetty服務器和servlet從版本9.2.2到版本9.3.8 在更新我的pom.xml文件後,我得到一些錯誤,如ServletContextHandler和ServletHolder是未找到 !更新jetty servlet 9.2.2到9.3.8

,這裏是我的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 

回答

1

您的依賴一個錯字。

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

非常感謝。其實我從碼頭網站複製它 http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets/9.3.8.v20160314 – SenanSharhan

+0

這不是碼頭的網站。 eclipse jetty項目建議通過mvnrepository.com使用[search.maven.org](https://search.maven.org/)(這是非常不準確和誤導性的) –

+0

好的!當我谷歌第一個網站是mvnrepository.com。感謝您的信息 – SenanSharhan