# spring-boot-demo-helloworld ## Runing spring boot demo helloworld ```sh $ mvn spring-boot:run ``` ## > 本 demo 演示如何使用 Spring Boot 写一个hello world ### pom.xml ```xml 4.0.0 spring-boot-demo-helloworld 1.0.0-SNAPSHOT jar spring-boot-demo-helloworld Demo project for Spring Boot com.xkcoding spring-boot-demo 1.0.0-SNAPSHOT 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 spring-boot-demo-helloworld org.springframework.boot spring-boot-maven-plugin ``` ### SpringBootDemoHelloworldApplication.java ```java /** *

* SpringBoot启动类 *

* * @author yangkai.shen * @date Created in 2018-09-28 14:49 */ @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); } } ``` ### application.yml ```yaml server: port: 8080 servlet: context-path: /demo ```