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 1.5 kB

7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # spring-boot-demo-helloworld
  2. 依赖 [spring-boot-demo-helloworld](../spring-boot-demo-parent)
  3. SpringBootDemoHelloworldApplication.java
  4. ```java
  5. @RestController
  6. @SpringBootApplication
  7. @Configuration
  8. public class SpringBootDemoHelloworldApplication {
  9. @Value("${spring.boot.demo.helloworld.data.version}")
  10. private String version;
  11. public static void main(String[] args) {
  12. SpringApplication.run(SpringBootDemoHelloworldApplication.class, args);
  13. }
  14. @GetMapping("/hello")
  15. public Map sayHello(@Value("${author}") String author, @Value("${exclusions}") String exclusions, @Value("${connectionProperties}") String connectionProperties) {
  16. Map<String, Object> result = Maps.newHashMap();
  17. result.put("ret", true);
  18. result.put("msg", StrUtil.format("hello,world,{}", author));
  19. Map<String, Object> data = Maps.newHashMap();
  20. data.put("version", version);
  21. data.put("exclusions", exclusions.split(","));
  22. Map<String, Object> connectionProperty = Maps.newHashMap();
  23. for (String connection : connectionProperties.split(";")) {
  24. String[] conn = connection.split("=");
  25. connectionProperty.put(conn[0], conn[1]);
  26. }
  27. data.put("connectionProperties", connectionProperty);
  28. result.put("data", data);
  29. return result;
  30. }
  31. }
  32. ```
  33. application.yml
  34. ```yml
  35. server:
  36. port: 8080
  37. context-path: /demo
  38. spring:
  39. boot:
  40. demo:
  41. helloworld:
  42. data:
  43. version: 1.0.0
  44. author: xkcoding
  45. exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
  46. connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
  47. ```

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

Contributors (1)