Spring Boot好处
- Spring Boot使编码变简单
- Spring Boot使配置变简单
- Spring Boot使部署变简单
- Spring Boot使监控变简单
创建Maven项目
步骤:IDE点击 NEW -> Maven Project -> Next
在filter中输入web或webapp 选择 maven-archetype-webapp
设置包名(Group Id)与项目名(Artifact Id),点击finish完成项目创建
Spring Boot Hello World
1.pom.xml中添加web支持模块
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2.编写Spring Boot启动类
3.编写HelloController
4.运行主程序测试
在main主函数入口右键Run as,选择Java Application
maven运行Spring Boot:选择项目 Run as -> Maven Build
访问项目不用添加项目名
如:http://localhost:8080/hello
否则会出现Web Error Page