vertx NoClassDefFoundError: io/netty/channel/EventLoopGroup [英] vertx NoClassDefFoundError: io/netty/channel/EventLoopGroup

查看:65
本文介绍了vertx NoClassDefFoundError: io/netty/channel/EventLoopGroup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但是为了运行一个简单的 verticle 示例,除了 vertx-core jar 之外还需要引用哪个 jar.我有这样的代码:

this is probably a stupid question, but which jar needs to be referenced besides vertx-core jar in order to run a simple verticle example. I have code like this:

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.当我运行代码时出现错误:

and searched through the vertx documentation but can't see which jar I ought to be referencing besides vertx-core jar. When I run the code I get the error:

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

推荐答案

谢谢!我需要 netty buffer、common 和 transport jars

Thanks! I needed netty buffer, common and transport jars

这篇关于vertx NoClassDefFoundError: io/netty/channel/EventLoopGroup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆