You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # spring-boot-demo-helloworld
  2. > 本 demo 演示如何使用 Spring Boot 写一个hello world
  3. ## pom.xml
  4. ```xml
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  8. <modelVersion>4.0.0</modelVersion>
  9. <artifactId>spring-boot-demo-helloworld</artifactId>
  10. <version>1.0.0-SNAPSHOT</version>
  11. <packaging>jar</packaging>
  12. <name>spring-boot-demo-helloworld</name>
  13. <description>Demo project for Spring Boot</description>
  14. <parent>
  15. <groupId>com.xkcoding</groupId>
  16. <artifactId>spring-boot-demo</artifactId>
  17. <version>1.0.0-SNAPSHOT</version>
  18. </parent>
  19. <properties>
  20. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  21. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  22. <java.version>1.8</java.version>
  23. </properties>
  24. <dependencies>
  25. <dependency>
  26. <groupId>org.springframework.boot</groupId>
  27. <artifactId>spring-boot-starter-web</artifactId>
  28. </dependency>
  29. <dependency>
  30. <groupId>org.springframework.boot</groupId>
  31. <artifactId>spring-boot-starter-test</artifactId>
  32. <scope>test</scope>
  33. </dependency>
  34. <dependency>
  35. <groupId>cn.hutool</groupId>
  36. <artifactId>hutool-all</artifactId>
  37. </dependency>
  38. </dependencies>
  39. <build>
  40. <finalName>spring-boot-demo-helloworld</finalName>
  41. <plugins>
  42. <plugin>
  43. <groupId>org.springframework.boot</groupId>
  44. <artifactId>spring-boot-maven-plugin</artifactId>
  45. </plugin>
  46. </plugins>
  47. </build>
  48. </project>
  49. ```
  50. ## SpringBootDemoHelloworldApplication.java
  51. ```java
  52. /**
  53. * <p>
  54. * SpringBoot启动类
  55. * </p>
  56. *
  57. * @package: com.xkcoding.helloworld
  58. * @description: SpringBoot启动类
  59. * @author: yangkai.shen
  60. * @date: Created in 2018/9/28 2:49 PM
  61. * @copyright: Copyright (c)
  62. * @version: V1.0
  63. * @modified: yangkai.shen
  64. */
  65. @SpringBootApplication
  66. @RestController
  67. public class SpringBootDemoHelloworldApplication {
  68. public static void main(String[] args) {
  69. SpringApplication.run(SpringBootDemoHelloworldApplication.class, args);
  70. }
  71. /**
  72. * Hello,World
  73. *
  74. * @param who 参数,非必须
  75. * @return Hello, ${who}
  76. */
  77. @GetMapping("/hello")
  78. public String sayHello(@RequestParam(required = false, name = "who") String who) {
  79. if (StrUtil.isBlank(who)) {
  80. who = "World";
  81. }
  82. return StrUtil.format("Hello, {}!", who);
  83. }
  84. }
  85. ```
  86. ## application.yml
  87. ```yaml
  88. server:
  89. port: 8080
  90. servlet:
  91. context-path: /demo
  92. ```

一个用来深度学习并实战 spring boot 的项目,目前总共包含 66 个集成demo,已经完成 55 个。