这可能是一个愚蠢的问题,但除了vertx-core jar之外,还需要引用哪个jar来运行一个简单的Verticle示例。我有这样的代码:
package examples.vertx;
import io.vertx.core.Vertx;
public class VertxApp {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new MyVerticle("name1"), stringAsyncResult -> {
System.out.println("MyVerticle deployed");
});
}
}
和
package examples.vertx;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
public class MyVerticle extends AbstractVerticle {
private String name = null;
public MyVerticle(String name) {
this.name = name;
}
@Override
public void start(Future<Void> startFuture) {
System.out.println("MyVerticle started!");
vertx.eventBus().consumer("test", message -> {
System.out.println(this.name + " received message: " + message.body());
});
}
@Override
public void stop(Future stopFuture) throws Exception {
System.out.println("MyVerticle stopped!");
}
}
并通过vertx文档搜索但是除了vertx-core jar之外我无法看到我应该引用哪个jar。当我运行代码时,我收到错误:
Exception in thread "main" java.lang.NoClassDefFoundError: io/netty/channel/EventLoopGroup
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:34)
at io.vertx.core.Vertx.vertx(Vertx.java:78)
at examples.vertx.VertxApp.main(VertxApp.java:9)
Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more