package xue.myVertX;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.ext.web.Router; /**
* 简单的路由使用
*/
public class SimpleRouter extends AbstractVerticle {
@Override
public void start() throws Exception {
// 创建HttpServer
HttpServer server = vertx.createHttpServer();
// 创建路由对象
Router router = Router.router(vertx);
// 监听/index地址
router.route("/index").handler(request -> {
request.response().end("INDEX SUCCESS");
});
// 把请求交给路由处理--------------------(1)
server.requestHandler(router::accept);
server.listen(8888);
} public static void main(String[] args) {
    Vertx.vertx().deployVerticle(new SimpleRouter());
  } 
}

1.

注意,Router包导入不要导错了,应该

import io.vertx.ext.web.Router;
否则会提示

2.

需要提前在maven导入依赖,当前使用版本

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>3.5.2</version>
</dependency>

更多版本在这里:https://mvnrepository.com/artifact/io.vertx/vertx-web

虽然只是导入了vertx-web,但是会下载很多东西,这些都是



最新文章

  1. 10道javascript笔试题
  2. swift基础语法(四) 函数、闭包(Closures)
  3. 创建 maven 本地仓库
  4. .NET学习记录2
  5. Phaser开源2d引擎 html5游戏框架中文简介
  6. lnmp一键安装包删除添加的域名
  7. 如何修改HDFS的备份数
  8. linux input输入子系统应用分析
  9. spring 解析配置文件问题
  10. C# 创建线程的简单方式:异步委托 .
  11. 时间格式nls_date_format的设置
  12. Jenkins中关于一些插件的使用方法
  13. 生成UUID简易版
  14. Spring Security(十一):4. Samples and Guides (Start Here)
  15. android checkBox选中与取消
  16. Zookeeper系列2 原生API 以及核心特性watcher
  17. 数据结构:IO读写频繁的青睐,B树和B+树
  18. Redis学习---Redis操作之List
  19. Unity面试问题归总
  20. 【转载】IDEA:放置型塔防备忘录

热门文章

  1. 图形学之Unity渲染管线流程
  2. useEffect无限调用问题
  3. 关于thinkPHP中的自动加载和手动导入
  4. A New Discrete Particle Swarm Optimization Algorithm
  5. grep的时候Binary file matches **.log 怎么解决
  6. Shell之awk常用用法
  7. xml数据结构处理
  8. 【LeetCode】845. Longest Mountain in Array 解题报告(Python)
  9. 1076 - Get the Containers
  10. bootstrap datetimepick 时分秒选择,坑我15个小时,整理记录