Quartz2.3.0 + Spring4.x 整合

pom.xml


        
            junit
            junit
            4.12
            test
        

        
            org.quartz-scheduler
            quartz
            2.3.0
        

        
            org.quartz-scheduler
            quartz-jobs
            2.3.0
        

        
            org.springframework
            spring-context
            4.3.13.RELEASE
        

        
            org.springframework
            spring-core
            4.3.13.RELEASE
        

        
            org.springframework
            spring-beans
            4.3.13.RELEASE
        

        
            org.springframework
            spring-test
            4.3.13.RELEASE
            test
        

        
            org.springframework
            spring-context-support
            4.3.13.RELEASE
        

        
            org.springframework
            spring-tx
            4.3.13.RELEASE
        

        
            org.springframework
            spring-web
            4.3.13.RELEASE
        

        
            org.springframework
            spring-webmvc
            4.3.13.RELEASE
        

        
            mysql
            mysql-connector-java
            5.1.13
        

        
            org.slf4j
            slf4j-api
            1.7.25
        

        
            log4j
            log4j
            1.2.17
        
    

spring配置文件application.xml




    
    
    
    
    
    
    
    
    
        
        
        
        
        
        
        
        
        
    

    
    
        
        
        
        
        
        
        
    

    
    
        
            
                
                
            
        
    

业务逻辑处理类TestQuartz

import java.text.SimpleDateFormat;
import java.util.Date;
import org.quartz.Scheduler;

public class TestQuartz {
    private Scheduler scheduler;
    
    public void dosomething(){
        Date now=new Date();
        System.out.println("执行任务:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now));
    }
}

测试

public static void main(String[] args) throws InterruptedException, SchedulerException {
        ApplicationContext context=new ClassPathXmlApplicationContext("classpath:application3.xml");
}

你可能感兴趣的:(Quartz2.3.0 + Spring4.x 整合)