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