效果圖:
在tomcat重啓的時候調用了一個刪除方法,主要是實現CommandLineRunner接口,這個接口比較好的就是可以使用@Order(value=1)這個註解,可以根據value的值來進行執行先後權限設置,1是最高權限,最先執行,不多說上乾貨~
Class:
package com.htsc.bcr.web; import com.htsc.bcr.service.AsyncJobService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; /** * @Author: xj * @Date: 2017/5/27 12:43 */ @Component public class InstallerClass implements CommandLineRunner { @Autowired private AsyncJobService asyncJobService; @Override @Transactional public void run(String... strings) throws Exception { asyncJobService.deleteAsyncJobByStart(); } }