diff --git a/demo-helloworld/README.md b/demo-helloworld/README.md
index d0c5cd8..6028b48 100644
--- a/demo-helloworld/README.md
+++ b/demo-helloworld/README.md
@@ -1,106 +1,58 @@
-# spring-boot-demo-helloworld
+## spring-boot-demo-helloworld
-## Runing spring boot demo helloworld
-
-```sh
- $ mvn spring-boot:run
-```
-##
> 本 demo 演示如何使用 Spring Boot 写一个hello world
-### pom.xml
-```xml
-
-
- * 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); - } +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.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 +#### 1.3.配置文件 application.yml ```yaml server: @@ -108,4 +60,8 @@ server: servlet: context-path: /demo ``` +### 2.测试 +启动 `Application.java` 打开任意浏览器: +- 输入 `http://localhost:8080/demo/hello` ,输出 `Hello, World!`; +- 输入 `http://localhost:8080/demo/hello?who=xkcoding` ,输出 `Hello, xkcoding!`。 diff --git a/demo-helloworld/pom.xml b/demo-helloworld/pom.xml index 25ec2d9..2f7040e 100644 --- a/demo-helloworld/pom.xml +++ b/demo-helloworld/pom.xml @@ -1,53 +1,50 @@- * SpringBoot启动类 + * 启动类 *
* * @author yangkai.shen - * @date Created in 2018-09-28 14:49 + * @date Created in 2022-08-12 20:10 */ @SpringBootApplication @RestController -public class SpringBootDemoHelloworldApplication { +public class Application { public static void main(String[] args) { - SpringApplication.run(SpringBootDemoHelloworldApplication.class, args); + SpringApplication.run(Application.class, args); } /** diff --git a/demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java b/demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java index 547e54b..8281a34 100644 --- a/demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java +++ b/demo-helloworld/src/test/java/com/xkcoding/helloworld/SpringBootDemoHelloworldApplicationTests.java @@ -1,16 +1,13 @@ package com.xkcoding.helloworld; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest -public class SpringBootDemoHelloworldApplicationTests { +class ApplicationTests { @Test - public void contextLoads() { + void contextLoads() { } } diff --git a/pom.xml b/pom.xml index e7223a0..263dc00 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@