0

私のメインコード

public static void main(String[] args) {
    System.out.println("Hello World!");
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "DataSource.xml");
    App app = applicationContext.getBean(App.class);
    app.start();
}

そして私の開始方法

public void start() {

    try {
        ServerSocket mobCom = new ServerSocket(9846);
        ExecutorService executorService = Executors.newCachedThreadPool();

        while (true) {
            Socket socket = mobCom.accept();
            PortService portService = new PortService(socket);
            executorService.submit(portService);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}

しかし、通信用の db クラスがあるため、PortService オブジェクトを直接ではなく Spring から作成する必要があります。どうすればいいのですか。

4

1 に答える 1