简体   繁体   English

软件包org.mortbay.http不存在。 如何在pom.xml中为此添加依赖项

[英]package org.mortbay.http does not exist. How to add dependencies for this in pom.xml

I'm trying to build my java project using maven. 我正在尝试使用Maven构建Java项目。 While compiling I'm getting the following error - 编译时出现以下错误-

package org.mortbay.http does not exist 
package org.mortbay.jetty does not exist 
package org.mortbay.jetty.servlet does not exist

I have added these dependencies at the last of my pom.xml file - 我在pom.xml文件的最后添加了这些依赖关系-

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>9.3.15.v20161220</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-http -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-http</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mortbay.jetty/jetty-util -->
<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>6.1.25</version>
</dependency>

I'm using SocketListener listener = new SocketListener(); 我正在使用SocketListener listener = new SocketListener(); and ServletHttpContext classes. ServletHttpContext类。 What changes do I need to make in my java class ? 我需要在java类中进行哪些更改?

org.mortbay.jetty have been replaced by org.eclipse.jetty (see maven jetty - org.mortbay.jetty vs org.eclipse.jetty ). org.mortbay.jetty已被org.eclipse.jetty取代(请参阅maven jetty-org.mortbay.jetty与org.eclipse.jetty )。

You should use the following dependencies : 您应该使用以下依赖项:

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-http</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlets</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>

and the packages : 和包装:

  • org.eclipse.jetty.server
  • org.eclipse.jetty.http
  • org.eclipse.jetty.servlets

Also, try to avoid mixing different versions of Jetty artifacts. 另外,请尝试避免混合使用不同版本的Jetty工件。

I found the right version for the dependency that covers for all the errors that I was getting. 我为依赖项找到了正确的版本,该依赖项涵盖了我所遇到的所有错误。

<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty</artifactId>
    <version>4.2.9</version>
</dependency>

With this dependency I was able to build my project and export a jar out of it. 有了这种依赖性,我就可以构建我的项目并从中导出一个jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM