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

我正在尝试使用 maven 构建我的 java 项目。编译时出现以下错误 -


package org.mortbay.http does not exist 

package org.mortbay.jetty does not exist 

package org.mortbay.jetty.servlet does not exist

我在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>

我正在使用SocketListener listener = new SocketListener();和ServletHttpContext类。我需要在我的 java 类中进行哪些更改?


江户川乱折腾
浏览 581回答 2
2回答

红颜莎娜

org.mortbay.jetty已被替换org.eclipse.jetty(参见maven jetty - org.mortbay.jetty vs org.eclipse.jetty)。您应该使用以下依赖项:<dependency>&nbsp; &nbsp; <groupId>org.eclipse.jetty</groupId>&nbsp; &nbsp; <artifactId>jetty-server</artifactId>&nbsp; &nbsp; <version>9.4.11.v20180605</version></dependency><dependency>&nbsp; &nbsp; <groupId>org.eclipse.jetty</groupId>&nbsp; &nbsp; <artifactId>jetty-http</artifactId>&nbsp; &nbsp; <version>9.4.11.v20180605</version></dependency><dependency>&nbsp; &nbsp; <groupId>org.eclipse.jetty</groupId>&nbsp; &nbsp; <artifactId>jetty-util</artifactId>&nbsp; &nbsp; <version>9.4.11.v20180605</version></dependency><dependency>&nbsp; &nbsp; <groupId>org.eclipse.jetty</groupId>&nbsp; &nbsp; <artifactId>jetty-servlets</artifactId>&nbsp; &nbsp; <version>9.4.11.v20180605</version></dependency>和包:org.eclipse.jetty.serverorg.eclipse.jetty.httporg.eclipse.jetty.servlets此外,尽量避免混合不同版本的 Jetty 工件。

catspeake

我找到了正确的依赖版本,涵盖了我遇到的所有错误。<dependency>&nbsp; &nbsp; <groupId>org.mortbay.jetty</groupId>&nbsp; &nbsp; <artifactId>jetty</artifactId>&nbsp; &nbsp; <version>4.2.9</version></dependency>有了这个依赖,我就能够构建我的项目并从中导出一个 jar。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java