按照老师的方式 配置好了配置文件但是启动后不执行 是什么原因
<bean id="SimpleTrigger" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="timing" />
<property name="targetMethod" value="run" />
<property name="concurrent" value="false"/>
</bean>
<bean id="myCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="SimpleTrigger"/>
<property name="cronExpression" value="0/5 * * ? * *"/>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="myCronTrigger"/>
</list>
</property>
</bean>
@Component("timing")
public class Timing {
public void run() {
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("MyBean Executes!" + sf.format(date));
}
}
配置文件没生效,你可以故意写错看会不会报错,不会报错,便是忘了将该xml文件import到application-context.xml(也许你起的是其他名字).
<property name="concurrent" value="false"/> 改成true试试