maven下Quartz定时器shiro,spring冲突问题

2018-07-30  本文已影响0人  帅气的小男孩q

1,pom.xml注意版本问题

2,spring-mvc.xml

<--!使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job接口,通过targetMethod指定调用方法-->

<bean id="taskJobWarning" class="com.dareway.jeedw.chapter24.util.timer.WarningTaskJob"/>  

<bean id="taskJobMethodWarning" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

<--! false表示等上一个任务执行完后再开启新的任务-->

<property name="concurrent" value="false"/>

<property name="targetObject">

<ref bean="taskJobWarning"/>

</property>

<property name="targetMethod">

<value>execute</value>

</property>

</bean>

<-- !调度触发器 -->

<bean id="myTriggerWarning" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">

<property name="jobDetail">

<ref bean="taskJobMethodWarning"/>

</property>

<property name="cronExpression"/>

<value>0/5 * * * * ?</value>

</property>

</bean>

<--! 调度工厂 -->

<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">

<property name="triggers"><list><ref bean="myTriggerWarning"/></list></property>

</bean>

3,WarningTaskJob类

public class WarningTaskJob {

    protected void execute() {

        DoSomething ds1 = new DoSomething();

        Thread t1 = new Thread(ds1);

        t1.start();

    }

}

  4,DoSomething类

public class DoSomething implements Runnable {

public DoSomething() {

}

public void run() {

        print("aaaa");

}

5,spring-config-shiro.xml冲突修改

<--! 会话验证调度器<bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.quartz.QuartzSessionValidationScheduler"><property name="sessionValidationInterval" value="1800000"/>

<property name="sessionManager" ref="sessionManager" />

</bean>-->修改为

<bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">

<property name="interval" value="1800000" />

<property name="sessionManager" ref="sessionManager"/></bean>

上一篇下一篇

猜你喜欢

热点阅读