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.4 kB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # spring-boot-demo-helloworld
  2. 依赖 [spring-boot-demo-parent](../spring-boot-demo-parent)
  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>0.0.1-SNAPSHOT</version>
  11. <packaging>war</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-parent</artifactId>
  17. <version>0.0.1-SNAPSHOT</version>
  18. <relativePath>../spring-boot-demo-parent/pom.xml</relativePath>
  19. </parent>
  20. <build>
  21. <finalName>spring-boot-demo-helloworld</finalName>
  22. </build>
  23. </project>
  24. ```
  25. ### SpringBootDemoHelloworldApplication.java
  26. ```java
  27. @RestController
  28. @SpringBootApplication
  29. @Configuration
  30. public class SpringBootDemoHelloworldApplication {
  31. @Value("${spring.boot.demo.helloworld.data.version}")
  32. private String version;
  33. public static void main(String[] args) {
  34. SpringApplication.run(SpringBootDemoHelloworldApplication.class, args);
  35. }
  36. @GetMapping("/hello")
  37. public Map sayHello(@Value("${author}") String author, @Value("${exclusions}") String exclusions, @Value("${connectionProperties}") String connectionProperties) {
  38. Map<String, Object> result = Maps.newHashMap();
  39. result.put("ret", true);
  40. result.put("msg", StrUtil.format("hello,world,{}", author));
  41. Map<String, Object> data = Maps.newHashMap();
  42. data.put("version", version);
  43. data.put("exclusions", exclusions.split(","));
  44. Map<String, Object> connectionProperty = Maps.newHashMap();
  45. for (String connection : connectionProperties.split(";")) {
  46. String[] conn = connection.split("=");
  47. connectionProperty.put(conn[0], conn[1]);
  48. }
  49. data.put("connectionProperties", connectionProperty);
  50. result.put("data", data);
  51. return result;
  52. }
  53. }
  54. ```
  55. ### application.yml
  56. ```yaml
  57. server:
  58. port: 8080
  59. context-path: /demo
  60. spring:
  61. boot:
  62. demo:
  63. helloworld:
  64. data:
  65. version: 1.0.0
  66. author: xkcoding
  67. exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
  68. connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
  69. ```

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

Contributors (1)