
本文共 1916 字,大约阅读时间需要 6 分钟。
������Spring Initializer������������Spring Boot������
���������IDE���������Spring Initializer������������Spring Boot���������������������������������������������������������������������Spring Boot IDE������������������������������������������������������
������������������������������������������������������������Spring Boot���������������������������������������������������������������������������������
���������Spring Boot���������������������
src/resources/
-
static: ������������������������������������JavaScript���CSS���������
-
templates: ���������������������������������FreeMarker���Thymeleaf������������
src/main/resources/
- application.properties: Spring Boot���������������������������������������������������������������������������������
���������������������������������������Spring Boot���������Main class:
package com.example.springboot;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public class SpringBoot01HelloworldQuickApplication {
public static void main(String[] args) { SpringApplication.run(SpringBoot01HelloworldQuickApplication.class, args);}
}
���������������������Spring Boot-entry point���������������������������������������
������������������������Hello World������������������
package com.example.springboot.controller;
import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController;
@RestController @RequestMapping("/api") public class HelloController {
@GetMapping("/hello")public String hello() { return "Hello Spring Boot!";}
}
������������������������������������������������������������������GET������������ endpoint "/api/hello"���
������������������������������Spring Boot���������������������
发表评论
最新留言
关于作者
