最新的Ver.x 4 从idea工具运行启动,并访问。项目创建通过vert.x官网生成器完成。
打开vert.x官网项目生成地址,https://start.vertx.io
如上图所示,设定好你的group id,artifactId 以及添加web依赖。然后点击下面得生成即可下载空项目。
使用idea打开项目,查看pom.xml依赖信息
构建信息啥的都是配置完成了得。
public class MainVerticle extends AbstractVerticle {
@Override
public void start(Promise<Void> startPromise) throws Exception {
vertx.createHttpServer().requestHandler(req -> {
req.response()
.putHeader("content-type", "text/plain")
.end("Hello from Vert.x!");
})
.listen(8888).onComplete(http -> {
if (http.succeeded()) {
startPromise.complete();
System.out.println("HTTP server started on port 8888");
} else {
startPromise.fail(http.cause());
}
});
}
}
在上图对应序号中分别添加以下配置
访问对应地址 http://localhost:8888,可以看到下面内容
至此最新的Ver.x 4 从idea工具运行启动就搞定了。
https://www.leftso.com/article/2408121508189860.html