unable to start the monitor on 4454 ,an other instance is problaly | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

unable to start the monitor on 4454 ,an other instance is problaly

点滴 admin 8年前 (2016-09-14) 4040次浏览 已收录 扫描二维码

        打开第二个Idea导入新项目,就会报这个错误,原因是由于Log4JPlugin造成的。启动这个插件会打开本机的4454进行socket通讯。

        在Log4Jplugin.jar中有一个LogServer类,代码如下:

        

        

package com.webspherious;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import javax.net.ServerSocketFactory;

public class LogServer
{
  private static final int PORT_NUM = 4454;
  private static ServerSocket serverSocket;

  public static void main(String[] args)
  {
    serverSocket = createServerSocket();
    listenAndPrintLogMessages();
  }

  private static void listenAndPrintLogMessages()
  {
    for (;;)
    {
      Socket socket = null;
      try
      {
        System.out.println(" >> Server waiting for log messages...");
        socket = serverSocket.accept();

        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        String line = null;
        while ((line = br.readLine()) != null) {
          System.out.println(line);
        }
        if (socket != null) {
          try
          {
            socket.close();
          }
          catch (IOException ignored) {}
        }
      }
      catch (Exception e) {}finally
      {
        if (socket != null) {
          try
          {
            socket.close();
          }
          catch (IOException ignored) {}
        }
      }
    }
  }

  private static ServerSocket createServerSocket()
  {
    ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault();
    try
    {
      serverSocket = serverSocketFactory.createServerSocket(4454);
    }
    catch (IOException ioEx)
    {
      System.err.println("Unable to create server");
      ioEx.printStackTrace();
      System.exit(-1);
    }
    return serverSocket;
  }
}

那么可以禁用或者修改端口配置。

喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。