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