不确定这是否是您想要的,但是您可以将一些配置值传递给Quartz作业。我相信在您的情况下,您可以利用
jobDataAsMap已经设置的属性,例如:
<property name="jobDataAsMap"> <map> <entry key="schedulerTask" value-ref="schedulerTask" /> <entry key="param1" value="com.custom.package.ClassName"/> </map> </property>
然后,您应该可以通过实际的Java代码以手动方式访问它:
protected void executeInternal(JobExecutionContext context) throws JobExecutionException { schedulerTask.printSchedulerMessage(); System.out.println(context.getJobDetail().getJobDataMap().getString("param1"));}或使用神奇的Spring方法-
param1使用getter / setter定义属性。您可以尝试使用
java.lang.Classtype
定义它,然后自动完成(Spring会为您完成):
private Class<?> param1; // getter & setter protected void executeInternal(JobExecutionContext context) throws JobExecutionException { schedulerTask.printSchedulerMessage(); System.out.println("Class injected" + getParam1().getName()); }我还没有测试过。



