From a5c94122fb5f772f5dc48d25ae889a20bd6b9a5e Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Mon, 15 Sep 2025 16:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AAspringboot=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springboot-web-quickstart/pom.xml | 75 +++++++++++++++++++ .../SpringbootWebQuickstartApplication.java | 13 ++++ .../inmind/controller/HelloController.java | 17 +++++ .../src/main/resources/application.properties | 3 + .../src/main/resources/static/index.html | 6 ++ ...ringbootWebQuickstartApplicationTests.java | 13 ++++ 6 files changed, 127 insertions(+) create mode 100644 springboot-web-quickstart/pom.xml create mode 100644 springboot-web-quickstart/src/main/java/com/inmind/SpringbootWebQuickstartApplication.java create mode 100644 springboot-web-quickstart/src/main/java/com/inmind/controller/HelloController.java create mode 100644 springboot-web-quickstart/src/main/resources/application.properties create mode 100644 springboot-web-quickstart/src/main/resources/static/index.html create mode 100644 springboot-web-quickstart/src/test/java/com/inmind/SpringbootWebQuickstartApplicationTests.java diff --git a/springboot-web-quickstart/pom.xml b/springboot-web-quickstart/pom.xml new file mode 100644 index 0000000..2936ef9 --- /dev/null +++ b/springboot-web-quickstart/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + com.inmind + springboot-web-quickstart + 0.0.1-SNAPSHOT + springboot-web-quickstart + springboot-web-quickstart + + 11 + UTF-8 + UTF-8 + 2.7.6 + + + + + org.springframework.boot + spring-boot-starter-web + + + + 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 + + 11 + 11 + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.inmind.SpringbootWebQuickstartApplication + true + + + + repackage + + repackage + + + + + + + + diff --git a/springboot-web-quickstart/src/main/java/com/inmind/SpringbootWebQuickstartApplication.java b/springboot-web-quickstart/src/main/java/com/inmind/SpringbootWebQuickstartApplication.java new file mode 100644 index 0000000..cf59f60 --- /dev/null +++ b/springboot-web-quickstart/src/main/java/com/inmind/SpringbootWebQuickstartApplication.java @@ -0,0 +1,13 @@ +package com.inmind; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication//表示默认启动项 +public class SpringbootWebQuickstartApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringbootWebQuickstartApplication.class, args); + } + +} diff --git a/springboot-web-quickstart/src/main/java/com/inmind/controller/HelloController.java b/springboot-web-quickstart/src/main/java/com/inmind/controller/HelloController.java new file mode 100644 index 0000000..92dfa5a --- /dev/null +++ b/springboot-web-quickstart/src/main/java/com/inmind/controller/HelloController.java @@ -0,0 +1,17 @@ +package com.inmind.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +//当前类是请求处理类 +@RestController +public class HelloController { + + //接收到请求资源路径为/hello,就由该方法处理请求 + @RequestMapping("/hello") + public String hello(){ + String s = "hello world"; + System.out.println(s); + return s; + } +} diff --git a/springboot-web-quickstart/src/main/resources/application.properties b/springboot-web-quickstart/src/main/resources/application.properties new file mode 100644 index 0000000..e52b498 --- /dev/null +++ b/springboot-web-quickstart/src/main/resources/application.properties @@ -0,0 +1,3 @@ +# 应用服务 WEB 访问端口 +server.port=8080 + diff --git a/springboot-web-quickstart/src/main/resources/static/index.html b/springboot-web-quickstart/src/main/resources/static/index.html new file mode 100644 index 0000000..89bb8ba --- /dev/null +++ b/springboot-web-quickstart/src/main/resources/static/index.html @@ -0,0 +1,6 @@ + + +

hello word!!!

+

this is a html page

+ + \ No newline at end of file diff --git a/springboot-web-quickstart/src/test/java/com/inmind/SpringbootWebQuickstartApplicationTests.java b/springboot-web-quickstart/src/test/java/com/inmind/SpringbootWebQuickstartApplicationTests.java new file mode 100644 index 0000000..265a020 --- /dev/null +++ b/springboot-web-quickstart/src/test/java/com/inmind/SpringbootWebQuickstartApplicationTests.java @@ -0,0 +1,13 @@ +package com.inmind; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringbootWebQuickstartApplicationTests { + + @Test + void contextLoads() { + } + +}