public static void shutdown() {
        try (Socket socket = new Socket(IP_ADDR, getShutDownPort());
             PrintWriter writer = new PrintWriter(socket.getOutputStream());
             BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
            writer.println(SHUTDOWN);
            writer.flush();
            LOG.info("shutdown服务器命令已发送...");
            String line;
            do {
                line = reader.readLine();
                LOG.info("server返回:" + line);
            } while (!SHUTDOWN_ACK.endsWith(line));
            LOG.info("服务器shutdown完毕:" + line);
            LOG.debug("等待较短时间，以便服务端java虚拟机退出.");
            Thread.sleep(500);
        } catch (Throwable t) {
            LOG.error("", t);
        }
    }
public static void shutdown ( ) { try ( Socket socket = new Socket ( IP_ADDR , getShutDownPort ( ) ) ; PrintWriter writer = new PrintWriter ( socket . getOutputStream ( ) ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( socket . getInputStream ( ) ) ) ) { writer . println ( SHUTDOWN ) ; writer . flush ( ) ; LOG . info ( "shutdown服务器命令已发送..." ) ; String line ; do { line = reader . readLine ( ) ; LOG . info ( "server返回:" + line ) ; } while ( ! SHUTDOWN_ACK . endsWith ( line ) ) ; LOG . info ( "服务器shutdown完毕:" + line ) ; LOG . debug ( "等待较短时间，以便服务端java虚拟机退出." ) ; Thread . sleep ( 500 ) ; } catch ( Throwable t ) { LOG . error ( "" , t ) ; } }
懒加载,可以防止本地执行main方法时总是报找不到配置文件的错误