Getting started with vert.x in java

Exposing web services using vert.x . For the beginners, follow steps and get started with the vert.x

  1. we need the below dependencies and it should be put in pom.xml file.
<! —
<! —

2. Create your class which extends AbstractVerticle

public class SimpleVertx extends AbstractVerticle {
public void start(Future<Void> fut) throws Exception {
Vertx vertx = Vertx.factory.vertx();
Router router = Router.router(vertx);“/user”).handler(this::createUser);
vertx.createHttpServer().requestHandler(router::accept).listen(config().getInteger(“http.port”, 8080),
result -> {
if (result.succeeded()) {
} else {“it failed”);
private void getUser(RoutingContext routingContext) {
User user = new User();
user.setName(“shashi raj”);
HttpServerResponse res = routingContext.response();
res.setStatusCode(200).putHeader(“content-type”, “application/json”).end(user.toString());
private void createUser(RoutingContext routingContext){
ObjectMapper mapper=new ObjectMapper();
User user=mapper.convertValue(routingContext.getBodyAsJson(), User.class);
HttpServerResponse res = routingContext.response();
res.setStatusCode(201).putHeader(“content-type”, “application/json”).end();

3. Now we need the below build module in pom to create FAT jar


4. we need to make sure that we have installed vert.x on our operating system . since I am using mac . so, mac users it can be download using following below steps

Install the App
Press Command+Space and type Terminal and press enter/return key.
Run in Terminal app:
ruby -e "$(curl -fsSL" < /dev/null 2> /dev/null
and press enter/return key. Wait for the command to finish.
brew install vert.x
Done! You can now use vert.x.

5. In order to run it from the command line , go to the directory and run below command

vertx run

6. Now we are done . just go and hit the same url in postman. And yes , we have started .

http://localhost:8080/user GET
http://localhost:8080/user POST 
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.