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