liurunyu
7 天以前 fcc1cf275578bd3aa08ef50c6a611fb206b7aac9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.dy.pipIrrParamSet;
 
import com.dy.pipIrrParamSet.console.CommandConsole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.io.Console;
 
/**
 * @Author: liurunyu
 * @Date: 2025/5/28 15:36
 * @Description
 */
@Component
public class Server {
 
    private CommandConsole mwConsole ;
 
    @Autowired
    public void setBean(CommandConsole console){
        this.mwConsole = console;
    }
 
    public void startServer() throws Exception{
        Console console = System.console();
        if (console == null) {
            throw new Exception("严重错误,未能得到控制台对象!");
        }
        mwConsole.init(console);
        boolean exit = mwConsole.execute() ;
        if(exit){
            System.exit(-1);
        }
    }
}