Spring boot使用 之 項目部署

1.部署基礎項目java

訪問:http://start.spring.io/web

點擊Generate Project下載壓縮包,解壓。spring

以Intellij Idea 16版本爲例 File->New->Project from Existing Sources...app

選擇Import project from external model 並選擇 maven,jdk選擇1.7(1.8)版本,而後靜靜等待maven工程自動下載依賴包。最終效果是這樣的maven

2.引入web模塊spring-boot

在pom.xml中添加依賴spa

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

在工程中添加controller包病建立DemoController類3d

@RestController
public class DemoController {
    @RequestMapping("/hello")
    public String index(){
        return "hello world";
    }
}

啓動服務後訪問 http://localhost:8080/hello 效果爲code

至此 咱們依靠Spring Initializr + maven完成了一個空白的web項目。xml

相關文章
相關標籤/搜索