如何在没有tomcat或任何类型的服务器的情况下在intellij上启动api应用程序?
我有一个使用vert.x框架创建的API应用程序,我能够构建应用程序,但无法运行。当我尝试运行应用程序时,我会自动重定向到cucumber.api.cli.main未找到错误。我删除了自动配置,但下次尝试运行应用程序时,它会生成。我应该在什么配置上运行如何在没有tomcat或任何类型的服务器的情况下在intellij上启动api应用程序?,api,intellij-idea,web-deployment,vert.x,Api,Intellij Idea,Web Deployment,Vert.x,我有一个使用vert.x框架创建的API应用程序,我能够构建应用程序,但无法运行。当我尝试运行应用程序时,我会自动重定向到cucumber.api.cli.main未找到错误。我删除了自动配置,但下次尝试运行应用程序时,它会生成。我应该在什么配置上运行 我已经尝试过对此进行研究,但大多数问题和答案都要求我设置tom cat服务器或glass fish服务器,我不想这样做 这是我的hello world应用程序,使用IntelliJ Idea,vert.x- 垂直线: 现在,您可以按照以下URL进
我已经尝试过对此进行研究,但大多数问题和答案都要求我设置tom cat服务器或glass fish服务器,我不想这样做 这是我的hello world应用程序,使用IntelliJ Idea,vert.x- 垂直线: 现在,您可以按照以下URL进行操作- 1. 2. 应用程序不需要运行tomcat 参考: 有用链接-
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.Router;
import static com.sun.xml.internal.ws.spi.db.BindingContextFactory.LOGGER;
public class MyVerticle extends AbstractVerticle {
@Override
public void start(Future<Void> startFuture) throws Exception {
Router router = Router.router(vertx);
router.route("/").handler(routingContext -> {
HttpServerResponse response = routingContext.response();
response.putHeader("content-type", "text/html")
.end("<h1> Hello Vert.x </h>");
});
vertx.createHttpServer().requestHandler(router::accept)
.listen(8070, http -> {
if (http.succeeded()) {
LOGGER.info("Started Server at port 8070");
} else {
startFuture.fail(http.cause());
}
});
vertx.createHttpServer().requestHandler(req -> {
req.response()
.putHeader("content-type", "text/plain")
.end("Hello from Vert.x!");
}).listen(8888, http -> {
if (http.succeeded()) {
startFuture.complete();
System.out.println("HTTP server started on port 8888");
} else {
startFuture.fail(http.cause());
}
});
router.route("/test").handler(routingContext -> {
HttpServerResponse response = routingContext.response();
response.putHeader("content-type","text/html")
.end("<h2> This is another end point with same port </h2>");
});
vertx.createHttpServer().requestHandler(router::accept).listen(8070,http ->{
if(http.succeeded()){
LOGGER.info("Another server started 8070");
}else{
startFuture.fail(http.cause());
}
});
}
@Override
public void stop() {
LOGGER.info("Shutting down application");
}
}
import com.testproject.starter.verticles.MyVerticle;
import io.vertx.core.Vertx;
public class MyVerticleTest {
public static void main(String[] args) {
Vertx vertex = Vertx.vertx();
MyVerticle myVerticle = new MyVerticle();
vertex.deployVerticle(myVerticle);
}
}