NutzCN Logo
问答 quartz插件在非mvc下的使用?
发布于 3043天前 作者 chenhuwo 2469 次浏览 复制 上一个帖子 下一个帖子
标签:
public static void main(String[] args) {
		Ioc ioc = new NutIoc(new JsonLoader("org/nutz/integration/quartz/quartz.js"));
		QuartzManager qm = ioc.get(QuartzManager.class, "quartzManager");
		
		QuartzJob job1 = new QuartzJob();
		job1.setJobName("job1");
		job1.setJobGroup("group1");
		job1.setCron("*/2 * * * * ?");
		job1.setClassName(HelloJob.class.getName());
		
		qm.add(job1);
	}


2016-08-23 10:43:34,002 [DefaultQuartzScheduler_QuartzSchedulerThread] DEBUG org.nutz.ioc.impl.NutIoc - Get 'helloJob'<class com.chw.test.quartz.HelloJob>
2016-08-23 10:43:34,002 [DefaultQuartzScheduler_QuartzSchedulerThread] DEBUG org.nutz.ioc.impl.NutIoc - 	 >> Load definition name=helloJob
2016-08-23 10:43:34,002 [DefaultQuartzScheduler_QuartzSchedulerThread] WARN  o.n.i.quartz.NutQuartzJobFactory - Not ioc bean? fallback to SimpleJobFactory
org.nutz.ioc.IocException: [helloJob] # For object [helloJob] - type:[class com.chw.test.quartz.HelloJob]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:226)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:265)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:150)
	at org.nutz.integration.quartz.NutQuartzJobFactory.newJob(NutQuartzJobFactory.java:27)
	at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
	at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'helloJob' without define!
	at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:174)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:188)
	... 5 common frames omitted

大神给讲讲

2 回复

非web环境下,一般不需要用ioc了吧?

static Ioc ioc;
public static void main(String[] args) {
		ioc = new NutIoc(new ComboIocLoader("*anoo", "填你的package", "*quartz"));
		// ... 其他代码
}

添加回复
请先登陆
回到顶部