![](/img/trans.png)
[英]Is it proper to set System property after Spring Boot application has started?
[英]How to change the Spring boot server time after it has been started
我正在使用Spring Boot構建一個應用程序,該應用程序具有幾個計划任務,這些任務在創建后一個月執行。 為了測試此服務,我需要將服務器時間更改為一個月后服務器運行的時間。 您能指導完成該步驟的步驟嗎?
為了進行測試,我建議您以Date為參數創建服務方法。 例如:
public void myScheduledTack(){
myDate = getCurrentDate();
myService.myMethod(myDate);
}
public getCurrentDate(){
return new Date();
}
使用這種模式,您可以模擬getCurrentDate方法並測試您的服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.