其实想在job里面去properties里面的配置的,结果连ioc都取不到,因为是不同线程所以取不到,那我想哪怎么办???
package com.ccb.znyw_batch.quartz.job;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Files;
import org.nutz.mvc.Mvcs;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.File;
@IocBean
public class SubmitJob implements Job {
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
PropertiesProxy conf = Mvcs.getIoc().get(PropertiesProxy.class, "conf");
String path = conf.get("scan.folder");
System.out.println(path);
File folder = new File(path);
File[] data = Files.files(folder, "dat");
for (File file : data) {
System.out.println(Files.read(file));
}
System.out.println("执行任务");
} catch (Exception e) {
e.printStackTrace();
}
}
}