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() { + } + +}