| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | |
| 6 | 6 | <encoder charset="UTF-8"> | |
| 7 | - <pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 7 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern> | ||
| 8 | 8 | </encoder> | |
| 9 | 9 | </appender> | |
| 10 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import org.springframework.boot.SpringApplication; | |
| 4 | 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
| 5 | + import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
| 6 | + import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; | ||
| 5 | 7 | import org.springframework.context.annotation.ComponentScan; | |
| 6 | 8 | import org.springframework.context.annotation.Configuration; | |
| 7 | 9 | import org.springframework.scheduling.annotation.EnableAsync; | |
@@ -22,7 +24,7 @@ | |||
| 22 | 24 | * Copyright(©) 2015 by xiaomo. | |
| 23 | 25 | **/ | |
| 24 | 26 | @Configuration | |
| 25 | - @EnableAutoConfiguration | ||
| 27 | + @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}) | ||
| 26 | 28 | @ComponentScan("info.xiaomo") | |
| 27 | 29 | @EnableScheduling | |
| 28 | 30 | @EnableAsync | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,20 +1,22 @@ | |||
| 1 | 1 | package info.xiaomo.scheduled.task; | |
| 2 | 2 | ||
| 3 | + import lombok.extern.slf4j.Slf4j; | ||
| 3 | 4 | import org.springframework.scheduling.annotation.Scheduled; | |
| 4 | 5 | import org.springframework.stereotype.Component; | |
| 5 | 6 | ||
| 6 | 7 | import java.text.SimpleDateFormat; | |
| 7 | 8 | import java.util.Date; | |
| 8 | 9 | ||
| 9 | 10 | @Component | |
| 11 | + @Slf4j | ||
| 10 | 12 | public class ScheduledTasks { | |
| 11 | 13 | ||
| 12 | 14 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); | |
| 13 | 15 | ||
| 14 | 16 | // 定义某个定时任务 | |
| 15 | 17 | @Scheduled(fixedRate = 5000) | |
| 16 | 18 | public void reportCurrentTime() { | |
| 17 | - System.out.println("当前时间:" + dateFormat.format(new Date())); | ||
| 19 | + log.debug("每5秒钟执行一次,注意观察日志时间"); | ||
| 18 | 20 | } | |
| 19 | 21 | ||
| 20 | 22 | ||
@@ -40,7 +42,7 @@ public void reportCurrentTime() { | |||
| 40 | 42 | //每1分钟执行一次 | |
| 41 | 43 | @Scheduled(cron = "0 */1 * * * * ") | |
| 42 | 44 | public void reportCurrentByCron() { | |
| 43 | - System.out.println("Scheduling Tasks Examples By Cron: The time is now " + dateFormat.format(new Date())); | ||
| 45 | + log.debug("每分钟执行一次,注意观察日志时间"); | ||
| 44 | 46 | } | |
| 45 | 47 | ||
| 46 | 48 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments