輸入一行,回車,觸發一次。如果想要調用service層,也是可以,能調用service層,就可以做很多事,觸發一次就好比調用了一次http接口一樣
package com.aircas.satellitemanagement;
import com.aircas.satellitemanagement.station.service.PlanFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import java.util.Scanner;
@SpringBootApplication
@ServletComponentScan
public class SatelliteManagementApplication implements CommandLineRunner {
@Autowired
PlanFileService planFileService;
public static void main(String[] args) {
SpringApplication.run(SatelliteManagementApplication.class, args);
}
@Override
public void run(String... args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String s = scanner.nextLine();
System.out.println("test::::::" + s);
planFileService.getAllPlanFile();
}
}
}