B
B
Boniface2014-11-08 16:24:19
Java
Boniface, 2014-11-08 16:24:19

How to work with Java vertx in Intellij idea?

Hello! Please tell me how to work with java vertx from intellij idea ...
I tried to generate a maven project, then I ran mvn idea:idea, as a result I got some kind of incomprehensible thing with a bunch of generated files, etc.
Then I tried to simply create an empty java project and added the following code to the main class:

class Server {

    public static void main(String[] args) throws IOException {

        DefaultVertxFactory f = new DefaultVertxFactory();
        Vertx vertx = f.createVertx();
        vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
            public void handle(HttpServerRequest req) {
                System.out.println("Got request: " + req.uri());
                System.out.println("Headers are: ");
                for (Map.Entry<String, String> entry : req.headers()) {
                    System.out.println(entry.getKey() + ":" + entry.getValue());
                }
                req.response().headers().set("Content-Type", "text/html; charset=UTF-8");
                req.response().end("Hello vertx!!!");
            }
        }).listen(8080);

        System.in.read();
    }
}

Everything works, it runs like a normal java console application (without the need to execute vertx run myclass.java). But it's not clear how much is right to do so. But all I really need is a debug from an idea.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boniface, 2014-11-08
@Boniface

I found the answer to my own question .. here everything is described in detail.
In a nutshell, you can do this, but you will have to implement scaling yourself and monitor thread safety.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question