使用vertx报错io.vertx.core.DeploymentOptions.isHa()Z
package com.cloudwise.vsphere;import java.io.IOException;
import java.util.function.Consumer;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.rxjava.core.Vertx;
import java.util.function.Consumer;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Handler;
import io.vertx.core.VertxOptions;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
public class Main extends AbstractVerticle {
/*
@Override
public void start() throws Exception {
super.start();
HttpServer server = vertx.createHttpServer();
server.requestHandler(request -> {
// This handler gets called for each request that arrives on the server
HttpServerResponse response = request.response();
response.putHeader("content-type", "text/plain;charset=utf-8");
// Write to the response and end it
response.end("你的人生流");
});
server.listen(8185);
}
*/
@Override
public void start() throws Exception {
final Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
// router.get("/hello")表示所监听URL路径
router.get("/hello").handler(new Handler<RoutingContext>() {
public void handle(RoutingContext event) {
event.response().putHeader("content-type", "text/html").end("Hello World");
}
});
// 传递方法引用,监听端口
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest event) {
router.accept(event);
}
}).listen(8185);// 监听端口号
}
@Override
public void stop() throws Exception {
// TODO Auto-generated method stub
super.stop();
}
/*
public static void main(String[] args) throws IOException {
Vertx.vertx().deployVerticle(com.cloudwise.vsphere.Main.class.getName());
DeploymentOptions workerDeploymentOptions = new DeploymentOptions();
// deployVerticle(vertx, VSphereApiTaskManagerVerticle.class, workerDeploymentOptions);
}
*/
public static void main(String[] args) throws IOException {
String verticleID = com.cloudwise.vsphere.Main.class.getName();
runExample(verticleID);
}
/**
* 功能:连接
* @param vertx
* @param verticleClass
* @param deploymentOptions
*/
public static void runExample(String verticleID) {
VertxOptions options = new VertxOptions();
Consumer<Vertx> runner = vertx -> {
vertx.deployVerticle(verticleID);
};
// Vert.x实例是vert.x api的入口点,我们调用vert.x中的核心服务时,均要先获取vert.x实例,
// 通过该实例来调用相应的服务,例如部署verticle、创建http server
Vertx vertx = Vertx.vertx(options);
runner.accept(vertx);
}
以上是 使用vertx报错io.vertx.core.DeploymentOptions.isHa()Z 的全部内容, 来源链接: utcz.com/p/177877.html