springboot在启动后,有些功能不需要通过接口调用才实现,而是一启动就开始执行
@SpringBootApplication
@MapperScan("com.vibration.detection.dao")
public class VibrationStart implements CommandLineRunner {
public static void main(String[] args) throws Exception {
SpringApplication.run(VibrationStart.class, args);
}
@Autowired
NettyTcpClient nettyTcpClient;
@Autowired
VibrationService vibrationService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
@Override
public void run(String... args) throws Exception {
nettyTcpClient.connect();
vibrationService.initVibrationMonitorConstant();
}
}