如何从IntelliJ IDEA启动Vert.x服务器? [英] How to start Vert.x server from IntelliJ IDEA?
问题描述
我的 build.gradle
如何从IntelliJ IDEA内部启动简单的Vert.x服务器?如下:
apply plugin:'java'
version ='3.0.0'
存储库{
mavenCentral()
}
依赖项{
编译'io.vertx:vertx-core:3.0.0'
}
我的Vertx服务器, MyVertex.java
如下:
package com.example;
导入io.vertx.core.AbstractVerticle;
导入io.vertx.core.Future;
public class MyVerticle extends AbstractVerticle {
$ b $ @Override
public void start(Future< Void> fut){
vertx.createHttpServer()
.requestHandler(r - > r.response()。end(< h1> Hello< / h1>))
.listen(8081);
$ / code>
我的IntelliJ运行配置如下, code> io.vertx.core.Starter 作为主要类:
< img src =https://i.stack.imgur.com/IwbQD.pngalt =在这里输入图片描述>
但是当
错误:无法找到或加载主类运行
VM选项(在运行配置中) run
我需要安装并添加到我的路径中,或者我如何开始使用Vert.x-server开发?
m使用vertx 3.2.1,它抱怨 io.vertx.core.Starter
。现在已弃用。因此,应该使用 io.vertx.core.Launcher
。
这是一个通过intellij启动指定配置JSON文件的选项:
io.vertx.core.Launcher $
<由您决定,或保留空白>
运行com.app.verticle.MyVerticle -conf /path/to/my_config.json
使用日志框架时,它将被添加到VM选项中,如下所示。
Log4j with 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
Logback: $ b
-Dvertx.logger-委托-FAC tory-class-name = io.vertx.core.logging.SLF4JLogDelegateFactory -Dlogback.configurationFile = logback.xml
How do I start a simple Vert.x server from inside IntelliJ IDEA?
My build.gradle
is as below:
apply plugin: 'java'
version = '3.0.0'
repositories {
mavenCentral()
}
dependencies {
compile 'io.vertx:vertx-core:3.0.0'
}
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);
}
}
And my IntelliJ run configuration is as below, with io.vertx.core.Starter
as 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
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?
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
.
This is an example of launching via intellij with the option of specifying a config JSON file:
- Main Class:
io.vertx.core.Launcher
- VM Options:
<up to you, or leave blank>
- Program Arguments:
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 with either log4j or 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
Logback:
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dlogback.configurationFile=logback.xml
这篇关于如何从IntelliJ IDEA启动Vert.x服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!