必见辽阔之地
简单地说就是Spring Boot可以让我们快速地创建独立的,产品级别的Spring应用。Spring Boot使用“习惯优于配置”的理念让我们可以很快地把项目运行起来,使用Spring Boot我们可以不用或者只需要很少的Spring配置。
本文使用的IDE是Intellij Idea
点击完成,项目就创建成功了。
新建一个简单的controller,仅仅是往页面返回一个字符串,因此用的是@RestController注解(方法名称随意)
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@RequestMapping("/hello")
public String index(){
return "Hello world. Welcome to learn spring boot!";
}
}
运行项目,然后在浏览器访问http://localhost:8080/hello
到目前为止,我们没写过一行配置,这就是Spring boot给我们带来的巨大好处,我们不需要做任何配置就可以把项目跑起来。
使用Spring Boot可以非常快速搭建项目,我们不需要或者只需要很少的Spring配置就可以创建一个生产级别的项目,所以Spring Boot非常适用于构建微服务。
2017-05-13 创建