From 37597634d841a95a34701ac20eca2863c0c4c8a0 Mon Sep 17 00:00:00 2001 From: liyuxin <1579178744@qq.com> Date: Mon, 22 Jul 2024 09:32:17 +0700 Subject: [PATCH] test04 --- .gitignore | 33 +++++++ pom.xml | 95 +++++++++++++++++++ .../java/com/bwie/test06/YourApplication.java | 12 +++ .../demos/ScheduledPrintNameService.java | 15 +++ src/main/resources/application.properties | 8 ++ src/main/resources/static/index.html | 6 ++ .../bwie/test06/Test06ApplicationTests.java | 13 +++ 7 files changed, 182 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/bwie/test06/YourApplication.java create mode 100644 src/main/java/com/bwie/test06/demos/ScheduledPrintNameService.java create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/static/index.html create mode 100644 src/test/java/com/bwie/test06/Test06ApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..25743fc --- /dev/null +++ b/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + com.bwie + test06 + 0.0.1-SNAPSHOT + test06 + test06 + + 1.8 + UTF-8 + UTF-8 + 2.6.13 + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.2 + + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.bwie.test06.Test06Application + true + + + + repackage + + repackage + + + + + + + + diff --git a/src/main/java/com/bwie/test06/YourApplication.java b/src/main/java/com/bwie/test06/YourApplication.java new file mode 100644 index 0000000..dd845c9 --- /dev/null +++ b/src/main/java/com/bwie/test06/YourApplication.java @@ -0,0 +1,12 @@ +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableScheduling +public class YourApplication { + + public static void main(String[] args) { + SpringApplication.run(YourApplication.class, args); + } +} diff --git a/src/main/java/com/bwie/test06/demos/ScheduledPrintNameService.java b/src/main/java/com/bwie/test06/demos/ScheduledPrintNameService.java new file mode 100644 index 0000000..178cb7e --- /dev/null +++ b/src/main/java/com/bwie/test06/demos/ScheduledPrintNameService.java @@ -0,0 +1,15 @@ +package com.bwie.test06.demos; + +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +@Service +public class ScheduledPrintNameService { + + // 每隔5秒钟执行一次任务 + @Scheduled(fixedRate = 5000) + public void printName() { + System.out.println("Scheduled task: Printing name..."); + // 可以在这里编写具体的任务逻辑 + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..6def5c2 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,8 @@ +#下面这些内容是为了让MyBatis映射 +#指定Mybatis的Mapper文件 +mybatis.mapper-locations=classpath:mappers/*xml +#指定Mybatis的实体目录 +mybatis.type-aliases-package=com.bwie.test06.mybatis.entity +# 应用服务 WEB 访问端口 +server.port=8080 + diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html new file mode 100644 index 0000000..f67da0a --- /dev/null +++ b/src/main/resources/static/index.html @@ -0,0 +1,6 @@ + + +

hello word!!!

+

this is a html page

+ + diff --git a/src/test/java/com/bwie/test06/Test06ApplicationTests.java b/src/test/java/com/bwie/test06/Test06ApplicationTests.java new file mode 100644 index 0000000..0430f09 --- /dev/null +++ b/src/test/java/com/bwie/test06/Test06ApplicationTests.java @@ -0,0 +1,13 @@ +package com.bwie.test06; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Test06ApplicationTests { + + @Test + void contextLoads() { + } + +}