如何从 IntelliJ IDEA 启动 Vert.x 服务器? [英] How to start Vert.x server from IntelliJ IDEA?

查看:38
本文介绍了如何从 IntelliJ IDEA 启动 Vert.x 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 IntelliJ IDEA 内部启动一个简单的 Vert.x 服务器?

How do I start a simple Vert.x server from inside IntelliJ IDEA?

我的build.gradle如下:

apply plugin: 'java'

version = '3.0.0'

repositories {
    mavenCentral()
}

dependencies {
    compile 'io.vertx:vertx-core:3.0.0'
}

我的 Vertx 服务器,MyVertex.java 如下:

My Vertx-server, MyVertex.java is as below:

package com.example;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;

public class MyVerticle extends AbstractVerticle {

    @Override
    public void start(Future<Void> fut) {
        vertx.createHttpServer()
                .requestHandler(r -> r.response().end("<h1>Hello</h1>"))
                .listen(8081);
    }
}

我的 IntelliJ 运行配置如下,以 io.vertx.core.Starter 作为主类:

And my IntelliJ run configuration is as below, with io.vertx.core.Starteras main class:

但是当我使用运行配置运行它时,我收到此错误消息:

But when I run it with my run configuration I get this error message:

Error: Could not find or load main class run

VM 选项(在运行配置中)run 是否需要安装并添加到我的路径中,或者我如何开始使用 Vert.x-server 开发?

Is the VM option (in Run configuration) run something I need to install and add to my path or how do I get started with Vert.x-server development?

推荐答案

我正在使用 vertx 3.2.1 并且它在抱怨 io.vertx.core.Starter.现在已弃用.所以,应该使用io.vertx.core.Launcher.

I'm using vertx 3.2.1 and it's complaining about io.vertx.core.Starter. It's deprecated now. So, one should use io.vertx.core.Launcher.

这是通过 Intellij 启动的示例,可选择指定配置 JSON 文件:

This is an example of launching via intellij with the option of specifying a config JSON file:

  • 主类:io.vertx.core.Launcher
  • VM 选项:<由您决定,或留空>
  • 程序参数:run com.app.verticle.MyVerticle -conf/path/to/my_config.json

当使用日志框架时,它将被添加到虚拟机选项中,如下所示.

When using a logging framework it will be added in VM Options as below.

Log4j 与 log4j 或 slf4j delgate:

-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.Log4jLogDelegateFactory -Dlog4j.configuration=log4j.xml

-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dlog4j.configuration=log4j.xml

登录:

-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dlogback.configurationFile=logback.xml

这篇关于如何从 IntelliJ IDEA 启动 Vert.x 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆