繁体   English   中英

启动后如何更改Spring Boot服务器的时间

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM