springboot非web应用


springboot使用方便,如果想使用springboot开发非web应用,只需要入口程序实现CommandLineRunner接口,Override run方法,即可。run方法为应用入口。

package com.bus.socketserver;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
public class SocketServerApplication implements CommandLineRunner {

    @SuppressWarnings("all")
    @Override
    public void run(String... args) throws Exception {
        System.in.read();
    }

    public static void main(String[] args) {
        SpringApplication.run(SocketServerApplication.class, args);
    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM