网页 综合 更新时间 2026-11-13 17:21:38

Get started | Eclipse Vert.x

自动蜘蛛 vertx.io 正文约 1575 字
In this guide, you’ll learn how to get started with a new Vert.x Web project.
Before starting, you need:
To create a new project, go to start.vertx.io.
Choose the version of Vert.x you want to use, choose Java as the language, Maven as the build tool, and type the group id and artifact id you want. Then, add Vert.x Web as a dependency by typing it in the “Dependencies” text box. When you’re done, hit the Generate Project button. Save the zip on your computer and unzip it in a folder of your choice.
The generated project contains:
If you want to try it now, you can download this sample project using Maven or using Gradle.
Open the project in the editor of your choice and navigate to src/main/java/com/example/starter/MainVerticle.java. This source file contains a sample Verticle (the Vert.x deployment unit) that starts an HTTP server. You’re going to modify it to greet whoever performs requests to your server. Change the code as follows:
This code creates a Vert.x Web Router (the object used to route HTTP requests to specific request handlers) and starts an HTTP Server on port 8888. On each request, it returns a JSON object containing the address of the request, the query parameter name, and a greeting message.
To run the code, open a terminal and navigate to your project folder. Build the application as follows:
Then, run the application:
Now that the server is up and running, try to send a request:
Now that you have had a taste of how easy and fun it is to get started with Vert.x, here are a few pointers to help guide you further along your journey:
访问原文 返回搜索 https://vertx.io/docs/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。