From 1601c9fa5c30ba45b19662787c61e3a82e1526ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=91=AB?= <1173628408@qq.com> Date: Mon, 22 Jul 2024 08:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=80=834?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 35 +++++++++++++++++++ pom.xml | 30 ++++++++++++++++ src/main/java/com/muyu/Rik04Application.java | 13 +++++++ .../schedule/ScheduledPrintNameService.java | 23 ++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/muyu/Rik04Application.java create mode 100644 src/main/java/com/muyu/schedule/ScheduledPrintNameService.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e403e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ee87047 --- /dev/null +++ b/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.muyu + rik04 + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + + org.springframework.boot + spring-boot-starter-parent + 2.7.15 + + + + + org.springframework.boot + spring-boot-starter + + + + diff --git a/src/main/java/com/muyu/Rik04Application.java b/src/main/java/com/muyu/Rik04Application.java new file mode 100644 index 0000000..6039975 --- /dev/null +++ b/src/main/java/com/muyu/Rik04Application.java @@ -0,0 +1,13 @@ +package com.muyu; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableScheduling +public class Rik04Application { + public static void main(String[] args) { + SpringApplication.run(Rik04Application.class); + } +} diff --git a/src/main/java/com/muyu/schedule/ScheduledPrintNameService.java b/src/main/java/com/muyu/schedule/ScheduledPrintNameService.java new file mode 100644 index 0000000..f117784 --- /dev/null +++ b/src/main/java/com/muyu/schedule/ScheduledPrintNameService.java @@ -0,0 +1,23 @@ +package com.muyu.schedule; + +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * @Author: WangXin + * @date: 2024/7/22 + * @Description: 任务类 + * @Version 1.0.0 + */ +@Component +public class ScheduledPrintNameService { + /** + * 每隔5秒输出自己的一次名字 + */ + @Scheduled(cron = " */5 * * * * ?") + public void printName(){ + System.out.println("wangXin "+ new Date()); + } +}