Spring Boot 学习笔记(二)

 新建Srping Boot 项目

以下是项目结构

由于Srping Boot内置Tomcat,所以不需要配置Tomcat就可以直接运行。

HelloWorldApplication是启动类,我们右击Run As 选择 Spring Boot app。

项目运行好之后

 

在浏览器输入:http://localhost:8080/

 看到这个页面项目就算启动好了。

然后新建一个HelloWorldController类

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {
@RequestMapping("/helloWorld")
public String say() {
return "HelloWorld";
}
}

然后我们重新启动HelloWorldApplication类

请求 http://localhost:8080/helloworld

 

 

posted @ 2017-10-04 18:07  风的呢喃Ⅱ  阅读(94)  评论(0)    收藏  举报