1
目前我使用的是cometd 3.0.2(最新版本)。试图做一个简单的握手它给了我下面的错误:哪个版本的jetty兼容cometd-3.0.2
随着码头7.4.4:
java.lang.NoClassDefFoundError: org/eclipse/jetty/client/api/ContentProvider
随着码头9.2.3:
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ajax/JSON
这是代码,我试图运行:
import java.util.HashMap;
import java.util.Map;
import org.cometd.client.BayeuxClient;
import org.cometd.client.transport.ClientTransport;
import org.cometd.client.transport.LongPollingTransport;
import org.eclipse.jetty.client.HttpClient;
public class MyClass {
public static void main(String[] args) throws Exception {
// Create (and eventually set up) Jetty's HttpClient:
HttpClient httpClient = new HttpClient();
// Here set up Jetty's HttpClient, for example:
// httpClient.setMaxConnectionsPerAddress(2);
httpClient.start();
// Prepare the transport
Map<String, Object> options = new HashMap<String, Object>();
ClientTransport transport = new LongPollingTransport(options, httpClient);
BayeuxClient client = new BayeuxClient("http://localhost:8080/cometd", transport);
client.handshake();
boolean handshaken = client.waitFor(1000, BayeuxClient.State.CONNECTED);
if (handshaken) {
System.out.println("Yey");
}
}
}
有没有人知道码头是否兼容最新cometd?或者其他任何cometd?
如果您使用的是maven,您可以发布您的pom.xml吗? – 2014-11-03 22:12:09
我没有使用maven。我一定要吗?对不起,我是新手。 – Dimme 2014-11-03 22:58:04
Maven并不是必需的,但是由于存在如此多的依赖关系,您可能需要研究maven或ant + ivy或gradle(真正的任何其他构建工具可以实现适当的传递依赖关系解析)。由于你所描述的问题只是尖叫坏/遗漏/错位的文物。 – 2014-11-03 23:23:53