Commit e80cb4fc by zhanghj

V1.1.0--完善定时任务项目

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@19558 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 7aba033d
......@@ -10,6 +10,7 @@
<groupId>com.glsx</groupId>
<artifactId>car-service-task</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>car-service-task</name>
<!-- FIXME change it to the project's website -->
......@@ -38,6 +39,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -2,12 +2,15 @@ package com.glsx.task;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
......@@ -25,6 +28,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@EnableDiscoveryClient
@MapperScan(basePackages={"com.glsx.task.mapper"})
@EnableScheduling
public class Application extends SpringBootServletInitializer{
/**
......
package com.glsx.task.schedule;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ScheduledTasks {
private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Scheduled(fixedRate = 5000)
public void reportCurrentTime() {
log.info("The time is now {}", dateFormat.format(new Date()));
}
}
##\u5f00\u53d1\u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u914d\u7f6e\u6587\u4ef6
spring.profiles.active=local
spring.application.name=car-service-task
logging.level.com.glsx.ordercenter=DEBUG
server.servlet.context-path=/carservice/task
server.port=8098
#eurekaClient
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
#configClient
spring.cloud.config.discovery.serviceId=car-service-config
spring.cloud.config.discovery.enabled=true
spring.cloud.config.profile=local
#\u5fc3\u8df3
#eureka.instance.lease-renewal-interval-in-seconds=5
##\u65e5\u5fd7 test
logging.level.com.glsx.usercenter=DEBUG
logging.path=/data/java_log/jetty/car-service-task
logging.config=classpath:logback.xml
#\u6307\u5b9adate\u8f93\u51fa\u683c\u5f0f\u4e3ayyyy-MM-dd HH:mm:ss
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
\ No newline at end of file
spring.application.name=car-service-task
server.port=8098
#configClient
spring.cloud.config.discovery.serviceId=car-service-config
spring.cloud.config.discovery.enabled=true
spring.cloud.config.profile=test
##\u65e5\u5fd7 test
logging.level.com.glsx.ordercenter=DEBUG
logging.path=/data/java_log/jetty/carService/car-service-task
logging.config=classpath:logback.xml
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!