打开第二个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; } }
那么可以禁用或者修改端口配置。