我正在尝试在spring mvc中应用任务调度。我遇到的问题是当调用被调度的函数时,它被调用两次。我希望该函数只调用一次。我附加了控制器和application-config.xml的代码。请帮我解决这个问题。
@Scheduled(cron = "0 0 1 * * ?")
@Async
public void WorkFlowPerformActionFunction() {
System.out.println("hello we are in workflow function");
}
application-config.xml中的代码
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<task:scheduler id="taskScheduler"/>
<task:executor id="taskExecutor" pool-size="10"/>
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler"/>
输出是:
hello we are in workflow function
hello we are in workflow function
我希望这个函数只调用一次而不是两次。