package com.mes.service; import com.mes.entity.DownGlassInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; @Component public class ThreadExample implements ApplicationRunner { @Autowired private DownGlassInfoService downGlassInfoService; @Override public void run(ApplicationArguments args) throws Exception { Thread thread = new Thread(() -> { DownGlassInfo downGlassInfo = downGlassInfoService.getDownGlassInfoById(1); // 设置需要查询的id System.out.println("Down Glass Info in new thread: " + downGlassInfo); }); thread.start(); } }