Starting Vert.x in Eclipse

Post on 29-Nov-2014

257 views 1 download

description

Vert.x is powerful but lots of vert.x starting examples shows only command-line methods. This is the way to start vert.x server development without terminal.

Transcript of Starting Vert.x in Eclipse

STARTING VERT.X IN ECLIPSEfourwingsy@gmail.com

MAKE NEW MAVEN PROJECT

ADD ARCHETYPE

NOW IT’S HERE

BUILD THE PROJECT AND…

SET RUN CONFIGURATION

SET RUN CONFIGURATION

SET RUN CONFIGURATION

SUCCESS!

CREATE HTTP VERTICLE

http://vertx.io/core_manual_java.html#writing-http-servers

public class HttpVerticle extends Verticle {

public void start() {HttpServer server = vertx.createHttpServer();server.requestHandler(new Handler<HttpServerRequest>() {

public void handle(HttpServerRequest request) {StringBuilder sb = new StringBuilder();for (Map.Entry<String, String> header : request.headers()

.entries()) {sb.append(header.getKey()).append(": ")

.append(header.getValue()).append("\n");}request.response().putHeader("content-type", "text/plain");request.response().end(sb.toString());

}});server.listen(8080, "localhost");

}}

BEFORE RUN…

change verticle class to run

AND RUN. THEN…

Run with configuration we made