想在nutz中执行定时任务,
就参照nutzbook中的【为正式开发做准备】的【加入Quartz】一步步操作方法:
加入的jar包是
quartz-2.2.3
nutz-integration-quartz-1.r.59
接下来就是添加修改
conf/quartz.properties
MainModule,修改IocBy
MainSetup类, 添加代码
运行后报错如下:
2017-06-08 15:50:52.473 DEBUG [localhost-startStop-1] org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(388) : SELECT COUNT(*) FROM tb_user
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(151) : Get 'nutQuartzCronJobFactory'<class org.nutz.integration.quartz.NutQuartzCronJobFactory>
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(177) : >> Load definition name=nutQuartzCronJobFactory
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.loader.map.MapLoader.load(67) : Loading define for name=nutQuartzCronJobFactory
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.loader.combo.ComboIocLoader.load(169) : Found IocObject(nutQuartzCronJobFactory) in QuartzIocLoader@19864874
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(209) : >> Make...'nutQuartzCronJobFactory'<class org.nutz.integration.quartz.NutQuartzCronJobFactory>
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(70) : Load class org.nutz.integration.quartz.NutQuartzCronJobFactory without AOP
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.ScopeContext.save(64) : Save object 'nutQuartzCronJobFactory' to [app]
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(151) : Get 'scheduler'<>
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(177) : >> Load definition name=scheduler
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.loader.map.MapLoader.load(67) : Loading define for name=scheduler
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.loader.combo.ComboIocLoader.load(169) : Found IocObject(scheduler) in QuartzIocLoader@19864874
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.NutIoc.get(209) : >> Make...'scheduler'<>
2017-06-08 15:50:52.504 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.ScopeContext.save(64) : Save object 'scheduler' to [app]
2017-06-08 15:50:52.520 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.ScopeContext.remove(84) : Remove object 'scheduler' from [app]
2017-06-08 15:50:52.520 DEBUG [localhost-startStop-1] org.nutz.ioc.impl.ScopeContext.remove(84) : Remove object 'nutQuartzCronJobFactory' from [app]
2017-06-08 15:50:52.520 ERROR [localhost-startStop-1] org.nutz.mvc.impl.NutLoading.load(125) : Error happend during start serivce!
org.nutz.ioc.IocException: [nutQuartzCronJobFactory, scheduler] # FAIL to create Ioc Bean name=[scheduler]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
at com.mgsoft.onekey.MainSetup.init(MainSetup.java:39)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at com.mgsoft.onekey.mvc.OneKeyNutFilter.init(OneKeyNutFilter.java:25)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4700)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5340)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/Logger
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at org.nutz.lang.Mirror.findMethod(Mirror.java:1133)
at org.nutz.lang.Mirror.findMethod(Mirror.java:1114)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:101)
... 27 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
... 35 more