From 3162ac39f075e1b5902ad67c2598af0cc759af33 Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Fri, 28 Sep 2018 15:01:00 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20spring-boot-demo-helloworld=20?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring-boot-demo-helloworld/.gitignore | 25 +++++++++ spring-boot-demo-helloworld/pom.xml | 56 +++++++++++++++++++ .../SpringBootDemoHelloworldApplication.java | 44 +++++++++++++++ .../src/main/resources/application.yml | 4 ++ ...ingBootDemoHelloworldApplicationTests.java | 16 ++++++ 5 files changed, 145 insertions(+) create mode 100644 spring-boot-demo-helloworld/.gitignore create mode 100644 spring-boot-demo-helloworld/pom.xml create mode 100644 spring-boot-demo-helloworld/src/main/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplication.java create mode 100644 spring-boot-demo-helloworld/src/main/resources/application.yml create mode 100644 spring-boot-demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java diff --git a/spring-boot-demo-helloworld/.gitignore b/spring-boot-demo-helloworld/.gitignore new file mode 100644 index 0000000..82eca33 --- /dev/null +++ b/spring-boot-demo-helloworld/.gitignore @@ -0,0 +1,25 @@ +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ \ No newline at end of file diff --git a/spring-boot-demo-helloworld/pom.xml b/spring-boot-demo-helloworld/pom.xml new file mode 100644 index 0000000..4fb21bd --- /dev/null +++ b/spring-boot-demo-helloworld/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + com.xkcoding + spring-boot-demo-helloworld + 0.0.1-SNAPSHOT + jar + + spring-boot-demo-helloworld + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.5.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + cn.hutool + hutool-all + 4.1.14 + + + + + spring-boot-demo-helloworld + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-demo-helloworld/src/main/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplication.java b/spring-boot-demo-helloworld/src/main/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplication.java new file mode 100644 index 0000000..b71825c --- /dev/null +++ b/spring-boot-demo-helloworld/src/main/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplication.java @@ -0,0 +1,44 @@ +package com.xkcoding.helloworld; + +import cn.hutool.core.util.StrUtil; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * SpringBoot启动类 + *

+ * + * @package: com.xkcoding.helloworld + * @description: SpringBoot启动类 + * @author: yangkai.shen + * @date: Created in 2018/9/28 2:49 PM + * @copyright: Copyright (c) + * @version: V1.0 + * @modified: yangkai.shen + */ +@SpringBootApplication +@RestController +public class SpringBootDemoHelloworldApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoHelloworldApplication.class, args); + } + + /** + * Hello,World + * + * @param who 参数,非必须 + * @return Hello, ${who} + */ + @GetMapping("/hello") + public String sayHello(@RequestParam(required = false, name = "who") String who) { + if (StrUtil.isBlank(who)) { + who = "World"; + } + return StrUtil.format("Hello, {}!", who); + } +} diff --git a/spring-boot-demo-helloworld/src/main/resources/application.yml b/spring-boot-demo-helloworld/src/main/resources/application.yml new file mode 100644 index 0000000..a02fbde --- /dev/null +++ b/spring-boot-demo-helloworld/src/main/resources/application.yml @@ -0,0 +1,4 @@ +server: + port: 8080 + servlet: + context-path: /demo \ No newline at end of file diff --git a/spring-boot-demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java b/spring-boot-demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java new file mode 100644 index 0000000..d4afb69 --- /dev/null +++ b/spring-boot-demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java @@ -0,0 +1,16 @@ +package com.xkcoding.helloworld; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringBootDemoHelloworldApplicationTests { + + @Test + public void contextLoads() { + } + +}