NutzCN Logo
问答 定时器一次执行两了次
发布于 2818天前 作者 qq_6c5a7e9a 2406 次浏览 复制 上一个帖子 下一个帖子
标签:
package hetaro.task;
import org.nutz.integration.quartz.annotation.Scheduled;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;  
  
/** 
 * 测试定时器 
 */
//@IocBean
@Scheduled(cron="20 51 * * * ?") 
public class TestSchedule implements Job{  
	@Override
	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		System.out.println("任务开始");
		System.out.println("大傻逼");
		System.out.println("任务结束");
	}
}
配置文件cron.pkgs=hetaro.task
任务开始
大傻逼
任务结束
任务开始
大傻逼
任务结束
5 回复

贴启动日志, 会打印类似这样的日志

job define name=XXX
二月 27, 2017 2:00:46 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HeTaro' did not find a matching property.
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Dec 5 2016 13:44:25 UTC
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         9.0.0.0
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 7
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            6.1
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:\Program Files\Java\jre1.8.0_92
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_92-b14
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         E:\Tomcat-9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         E:\Tomcat-9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:61569
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=E:\Tomcat-9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=E:\Tomcat-9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=E:\Tomcat-9.0.0.M15\webapps
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=E:\Tomcat-9.0.0.M15\endorsed
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
二月 27, 2017 2:00:46 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_92\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_92/bin/server;C:/Program Files/Java/jre1.8.0_92/bin;C:/Program Files/Java/jre1.8.0_92/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;E:\Git\cmd;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;D:\Tesseract-OCR;C:\Program Files\TortoiseGit\bin;D:\HuTao\SVN\bin;C:\Users\java\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_92\bin;C:\Program Files\Java\jdk1.8.0_92\jre\bin;C:\Program Files\Bandizip\7z;E:\eclipse;;.
二月 27, 2017 2:00:46 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
二月 27, 2017 2:00:46 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
二月 27, 2017 2:00:46 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
二月 27, 2017 2:00:46 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
二月 27, 2017 2:00:46 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 505 ms
二月 27, 2017 2:00:46 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
二月 27, 2017 2:00:46 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/9.0.0.M15
二月 27, 2017 2:00:46 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[INFO ] 14:00:47.113 org.nutz.mvc.NutFilter._init(NutFilter.java:81) - NutFilter[nutz] starting ...
[INFO ] 14:00:47.263 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:55) - Nutz Version : 1.r.60 
[INFO ] 14:00:47.263 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:56) - Nutz.Mvc[nutz] is initializing ...
[INFO ] 14:00:47.319 org.nutz.ioc.loader.annotation.AnnotationIocLoader.<init>(AnnotationIocLoader.java:50) - Found 4 classes in 1 base-packages!
beans = ["testSchedule", "userModules", "userDao", "userService"]
[INFO ] 14:00:47.325 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:98) - NutIoc init begin ...
[INFO ] 14:00:47.327 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:115) - ... NutIoc init complete
[INFO ] 14:00:47.330 org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:159) - Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
[INFO ] 14:00:47.344 org.nutz.mvc.impl.NutActionChainMaker.getProcessorByName(NutActionChainMaker.java:72) - Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
[INFO ] 14:00:47.350 org.nutz.mvc.impl.NutActionChainMaker.getProcessorByName(NutActionChainMaker.java:72) - Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
[INFO ] 14:00:47.357 org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:220) - Found 3 module methods
[INFO ] 14:00:47.358 org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:274) - Setup application...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO ] 14:00:47.430 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:141) - Nutz.Mvc[nutz] is up in 166ms
二月 27, 2017 2:00:47 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory E:\Tomcat-9.0.0.M15\webapps\HeTaro
二月 27, 2017 2:00:47 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[INFO ] 14:00:47.848 org.nutz.mvc.NutFilter._init(NutFilter.java:81) - NutFilter[nutz] starting ...
[INFO ] 14:00:48.013 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:55) - Nutz Version : 1.r.60 
[INFO ] 14:00:48.013 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:56) - Nutz.Mvc[nutz] is initializing ...
[INFO ] 14:00:48.068 org.nutz.ioc.loader.annotation.AnnotationIocLoader.<init>(AnnotationIocLoader.java:50) - Found 4 classes in 1 base-packages!
beans = ["testSchedule", "userModules", "userDao", "userService"]
[INFO ] 14:00:48.076 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:98) - NutIoc init begin ...
[INFO ] 14:00:48.077 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:115) - ... NutIoc init complete
[INFO ] 14:00:48.079 org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:159) - Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
[INFO ] 14:00:48.093 org.nutz.mvc.impl.NutActionChainMaker.getProcessorByName(NutActionChainMaker.java:72) - Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
[INFO ] 14:00:48.149 org.nutz.mvc.impl.NutActionChainMaker.getProcessorByName(NutActionChainMaker.java:72) - Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
[INFO ] 14:00:48.156 org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:220) - Found 3 module methods
[INFO ] 14:00:48.156 org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:274) - Setup application...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO ] 14:00:48.224 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:141) - Nutz.Mvc[nutz] is up in 210ms
二月 27, 2017 2:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory E:\Tomcat-9.0.0.M15\webapps\HeTaro has finished in 783 ms
二月 27, 2017 2:00:48 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler [http-nio-8080]
二月 27, 2017 2:00:48 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler [ajp-nio-8009]
二月 27, 2017 2:00:48 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1883 ms

貌似启动日志也打印了两次

这是在eclipse里面启动,还是部署到tomcat目录了?

eclipse,右击服务器,左击debug模式启动

把tomcat删了,重新弄一个

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