Browse Source

定时器改成注解方式

liupeng 4 years ago
parent
commit
b4012dd119

+ 3 - 2
code/sapparent/sapcms/src/main/resources/spring-content.xml

@@ -18,7 +18,9 @@
 		   http://www.springframework.org/schema/cache
 		   http://www.springframework.org/schema/cache/spring-cache.xsd
 		   http://www.springframework.org/schema/context  
-		   http://www.springframework.org/schema/context/spring-context-4.3.xsd">
+		   http://www.springframework.org/schema/context/spring-context-4.3.xsd
+		   http://www.springframework.org/schema/task 
+		   http://www.springframework.org/schema/task/spring-task-4.3.xsd">
 	<!-- 加载配置文件 -->
 	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 		<property name="locations">
@@ -31,7 +33,6 @@
 	<!-- import文件 -->
 	<import resource="spring/dataSource.xml"/>
 	<import resource="spring/shiro.xml"/>
-	<import resource="spring/quartz.xml"/>
 	<!-- 自动完成声明 -->
 	<context:annotation-config />
 	<!-- 设置上传文件的最大尺寸 -->

+ 13 - 0
code/sapparent/sapservice/src/main/java/org/fouram/job/AutoCheckJob.java

@@ -0,0 +1,13 @@
+package org.fouram.job;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AutoCheckJob {
+
+	@Scheduled(cron = "0/10 * * * * ?")
+	public void execute() {
+		System.out.println("1");
+	}
+}

+ 0 - 36
code/sapparent/sapservice/src/main/resources/spring/quartz.xml

@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:context="http://www.springframework.org/schema/context"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
-	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
-	xsi:schemaLocation="
-	   http://www.springframework.org/schema/beans
-	   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-	   http://www.springframework.org/schema/tx
-	   http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
-	   http://www.springframework.org/schema/aop
-	   http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
-	   http://www.springframework.org/schema/context
-	   http://www.springframework.org/schema/context/spring-context-4.3.xsd
-	   http://www.springframework.org/schema/mvc
-	   http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"
-	default-autowire="byName">
-
-<!--	<bean id="syncWeixinUserJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  -->
-<!--		<property name="targetObject" ref="taskService" />  -->
-<!--		<property name="targetMethod" value="syncWeixinUser" />  -->
-<!--		<property name="concurrent" value="false" />-->
-<!--	</bean>-->
-<!--	<bean id="syncWeixinUserTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">  -->
-<!--		<property name="jobDetail" ref="syncWeixinUserJob" />-->
-<!--		<property name="cronExpression" value="0 0 0/1 * * ?" />-->
-<!--	</bean>-->
-<!--	-->
-<!--	<bean id="schedulerFactorys" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">-->
-<!--		<property name="triggers">-->
-<!--			<list>-->
-<!--				<ref bean="syncWeixinUserTrigger" />-->
-<!--			</list>-->
-<!--		</property>-->
-<!--	</bean>-->
-</beans>