diff --git a/spring-boot-demo-helloworld/README.md b/spring-boot-demo-helloworld/README.md new file mode 100644 index 0000000..9c907cc --- /dev/null +++ b/spring-boot-demo-helloworld/README.md @@ -0,0 +1,55 @@ +# spring-boot-demo-helloworld + +依赖 [spring-boot-demo-helloworld](../spring-boot-demo-parent) + +SpringBootDemoHelloworldApplication.java + +```java +@RestController +@SpringBootApplication +@Configuration +public class SpringBootDemoHelloworldApplication { + @Value("${spring.boot.demo.helloworld.data.version}") + private String version; + + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoHelloworldApplication.class, args); + } + + @GetMapping("/hello") + public Map sayHello(@Value("${author}") String author, @Value("${exclusions}") String exclusions, @Value("${connectionProperties}") String connectionProperties) { + Map result = Maps.newHashMap(); + result.put("ret", true); + result.put("msg", StrUtil.format("hello,world,{}", author)); + Map data = Maps.newHashMap(); + data.put("version", version); + data.put("exclusions", exclusions.split(",")); + Map connectionProperty = Maps.newHashMap(); + for (String connection : connectionProperties.split(";")) { + String[] conn = connection.split("="); + connectionProperty.put(conn[0], conn[1]); + } + data.put("connectionProperties", connectionProperty); + result.put("data", data); + return result; + } +} +``` + +application.yml + +```yml +server: + port: 8080 + context-path: /demo +spring: + boot: + demo: + helloworld: + data: + version: 1.0.0 +author: xkcoding +exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" +connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 +``` +