From 48c20ea6c17a5a7904251c7bb404e740ecb81a48 Mon Sep 17 00:00:00 2001 From: root <254926827@qq.com> Date: Mon, 18 Nov 2024 11:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 39 +++++++++++++++++++ .../cn/wolfcode/SpringBootDockerServer.java | 12 ++++++ .../wolfcode/controller/UserController.java | 21 ++++++++++ src/main/resources/application.yml | 2 + 4 files changed, 74 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/cn/wolfcode/SpringBootDockerServer.java create mode 100644 src/main/java/cn/wolfcode/controller/UserController.java create mode 100644 src/main/resources/application.yml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..aa8fc94 --- /dev/null +++ b/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + + + org.springframework.boot + spring-boot-starter-parent + 2.3.2.RELEASE + + + cn.wolfcode + springboot-docker-demo + 1.0-SNAPSHOT + + + 8 + 8 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/cn/wolfcode/SpringBootDockerServer.java b/src/main/java/cn/wolfcode/SpringBootDockerServer.java new file mode 100644 index 0000000..8f4be38 --- /dev/null +++ b/src/main/java/cn/wolfcode/SpringBootDockerServer.java @@ -0,0 +1,12 @@ +package cn.wolfcode; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootDockerServer { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDockerServer.class, args); + } +} diff --git a/src/main/java/cn/wolfcode/controller/UserController.java b/src/main/java/cn/wolfcode/controller/UserController.java new file mode 100644 index 0000000..020ba64 --- /dev/null +++ b/src/main/java/cn/wolfcode/controller/UserController.java @@ -0,0 +1,21 @@ +package cn.wolfcode.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; + +@RestController +@RequestMapping("/users") +public class UserController { + + @GetMapping("/{name}") + public HashMap index(@PathVariable String name) { + HashMap map = new HashMap<>(); + map.put("id", Math.random() + 1); + map.put("name", name); + return map; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..1c4b38a --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: 9080