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

标签 java maven jetty pom.xml maven-jetty-plugin

我正在尝试使用 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>

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

最佳答案

org.mortbay.jetty 已被 org.eclipse.jetty 取代(请参阅 maven jetty - org.mortbay.jetty vs org.eclipse.jetty )。

您应该使用以下依赖项:

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

和包:

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

此外,尽量避免混合不同版本的 Jetty Artifact 。

关于java - org.mortbay.http 包不存在。如何在 pom.xml 中为此添加依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51893921/

相关文章:

java 正则表达式匹配 &[text(text - text text) !text]

用于比较 2 个图形的 Java 图形库

java - 对于复杂类型,SOAP 响应在 <item> 中包含 xmlns =""

java - 如何从 Ant 启动聚合 jetty-server JAR?

java - 从每一行JAVA替换字符串的两个第一个字符的最佳方法

java - 由于 CHECKSUM FAILED,我如何处理我的 Maven 构建中缺少的远程资源

maven - 为什么 <excludeGroups> 起作用而 <groups> 不起作用?

maven - 使用 maven-jaxb2-plugin 从多个 wsdl 文件生成类

web-services - c3p0 回滚事务而不是提交

tomcat - 根本不发送响应头