導入步驟;File - >Import -> Existing Maven Projects -> Next ->選擇解壓之後的文件夾 - >Finish。java
工程目錄:web
DemoApplication.java是Spring Boot的啓動類:spring
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
接着能夠直接進行開發,編寫一個Controller類。api
package com.example.demo.controller; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @SpringBootApplication @RequestMapping("/springboot") public class HelloController { @RequestMapping("/hello") public String hello() { return "Hello Spring Boot"; } }
Spring Boot項目不須要單獨部署到Tomcat或者Jetty中才能啓動,經過Spring Boot啓動器,SpringBoot會自動構建一個web容器,並將項目部署到其中。DemoApplication.java右鍵 -> Run As - > Spring Boot App,工程就啓動了。springboot
使用Postman GET方式請求http://localhost:8080/springboot/hello ,能夠看到返回了「Hello Spring Boot」。app