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

相关文章
相关标签/搜索