Spring Boot官方文档学习_暂存
https://spring.io/projects/spring-boot
2023-04-06;
1.DemoApplication.java;
@SpringBootApplication @RestController public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } @GetMapping("/hello") public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { return String.format("Hello %s!", name); } }
2.HelloController.java;
@RestController public class HelloController { @GetMapping("/") public String index() { return "Greetings from Spring Boot!"; } }
3.Application.java;
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public CommandLineRunner commandLineRunner(ApplicationContext ctx) { return args -> { System.out.println("Let's inspect the beans provided by Spring Boot:"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames); for (String beanName : beanNames) { System.out.println(beanName); } }; } }
2023-04-08;
1.HelloController.java;
@RestController public class HelloController { @GetMapping("/") public String index() { return "Greetings from Spring Boot"; } }
进行到 https://spring.io/guides/gs/spring-boot/ 的“run the application”小结。