在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  網(wǎng)絡(luò)安全/ About vertx, java.net.BindException: Add

About vertx, java.net.BindException: Address already in use

Now, I begin to learn vert.x.

At first, I tried to define a function that can work.

However, 當(dāng)我第二次運(yùn)行程序的時(shí)候, my current implementation gives me the following error:

三月 22, 2018 3:29:23 下午 io.vertx.core.http.impl.HttpServerImpl
嚴(yán)重: java.net.BindException: Address already in use

我希望第二次運(yùn)行時(shí),可以首先檢測下端口,如果端口被占用,先關(guān)閉端口

I could not find an answer from the documentation.

Source code

package com.project.service;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.ext.web.Router;

import java.util.function.Consumer;

public class VerticleMain extends AbstractVerticle {


    @Override
    public void start() throws Exception {

        Router router = Router.router(vertx);

        router.route().handler(routingContext -> {
            routingContext.response()
                    .putHeader("content-type","text/html;charset=UTF-8")
                    .end("我的人設(shè)開始");
        });
        vertx.createHttpServer().requestHandler(router::accept).listen(8181);
    }

    public static void deployVertx() {
        String verticleId = VerticleMain.class.getName();
        VertxOptions options = new VertxOptions();
        Consumer<Vertx> runner = vertxStart -> {
            vertxStart.deployVerticle(verticleId);
        };
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }

    public static void main(String[] args) {

        VerticleMain.deployVertx();
    }
}
回答
編輯回答
下墜

好像關(guān)閉端口占用,是要關(guān)閉占用端口的系統(tǒng)進(jìn)程吧
你要先去查是哪個(gè)進(jìn)程占用了該端口,然后在kill進(jìn)程

其實(shí)你第一次運(yùn)行完了關(guān)閉程序就可以了哇,何必搞的這么麻煩

2017年1月21日 18:01