我有Maven的項目中下面的代碼:IntelliJ和Vertx:如何運行org.vertx.java.deploy.impl.cli.Starter?
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中以下依賴性:
<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應用程序:
,我也得到了許多錯誤:
Error:(7, 8) java: hello.Server is not abstract and does not override abstract method stop(io.vertx.core.Future) in io.vertx.core.Verticle Error:(12, 57) java: cannot find symbol
symbol: variable uri location: variable req of type io.vertx.core.http.HttpServerRequest Error:(14, 48) java: cannot find symbol symbol: method keySet() location: interface io.vertx.core.MultiMap Error:(17, 20) java: cannot find symbol
symbol: variable response location: variable req of type io.vertx.core.http.HttpServerRequest Error:(18, 20) java: cannot find symbol symbol: variable response location: variable req of type io.vertx.core.http.HttpServerRequest Error:(9, 9) java: cannot find symbol symbol: variable vertx location: class hello.Server
然而,當我從這裏下載vert.x jar文件: http://vertx.io/download/
,並把它們在項目結構,則同樣的代碼編譯成功。
大概我需要pom.xml中的另一個依賴項,但我不知道它應該是什麼。
相關https://stackoverflow.com/questions/32205477/how-to-start-vert-x-server-from-intellij-idea – Jonas