本文介绍了IntelliJ和Vertx:如何运行org.vertx.java.deploy.impl.cli.Starter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在Maven项目中有以下代码:

I have the following code inside Maven project:

package hello;

import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;


public class Server extends Verticle {
    public void start() {
        vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
            @Override
            public void handle(HttpServerRequest req) {
                System.out.println("Got request: " + req.uri);
                System.out.println("Headers are: ");
                for (String key : req.headers().keySet()) {
                    System.out.println(key + ":" + req.headers().get(key));
                }
                req.response.headers().put("Content-Type", "text/html; charset-UTF-8");
                req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");
            }
        }).listen(4000);
    }
}

我在pom.xml中也有以下依赖项:

I also have the following dependency in pom.xml:

<dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>org.vert-x</groupId>
            <artifactId>vertx-platform</artifactId>
            <version>1.2.3.final</version>
        </dependency>

我尝试使用以下配置在IntelliJ中运行Java应用程序:

I try to run Java application in IntelliJ with the following configuration:

我收到很多错误:

然而,当我从这里下载vert.x jar文件时:

However, when I download vert.x jar files from here:http://vertx.io/download/

并将它们放入项目结构中,然后相同代码编译成功。

and put them in the project structure, then the same code compiles successfully.

可能我需要在pom.xml中有另一个依赖项,但我不知道它应该是什么。

Probably I need another dependency in pom.xml, but I don't know what it should be.

推荐答案

你不应该有依赖:

    <dependency>
        <groupId>org.vert-x</groupId>
        <artifactId>vertx-platform</artifactId>
        <version>1.2.3.final</version>
    </dependency>

因为它与Vert.x 1.2相关,而你的应用程序与3.x相关。在这种情况下,您的主要类应该是:

Since it related to Vert.x 1.2 and your application in on 3.x. In this case your main class should be:

    io.vertx.core.Launcher

或者你可以从那里添加 main 方法并进行调试,例如:

Alternatively you could add a main method and debug from there, for example:

public class Server extends Verticle {
  public static void main(String[] args) {
    Vertx.vertx().deployVerticle(new Server());
  }
}

现在您无需担心添加启动器配置文件,只需右键单击并运行/调试。

Now you don't need to worry about adding launcher profiles, just right click and run/debug.

这篇关于IntelliJ和Vertx:如何运行org.vertx.java.deploy.impl.cli.Starter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 22:51