1.创建一个maven工程
导入spring boot依赖
所有Springboot工程必须继承,spring-boot-starter-parent
web功能依赖,spring-boot-starter-web
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
编写引导类
借助main方法运行springboot
run方法 表示运行springBoot引导类 run的参数就是Spring boot引导类的字节码对象
package it.heima;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootApp {
public static void main(String[] args) {
SpringApplication.run(SpringbootApp.class);
}
}
快速入门
package it.heima.Controllor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class QuickContorllor {
@RequestMapping("/quick")
@ResponseBody
public String quick(){
return "hello Spring";
}
}
热部署
对代码更改后,不需要停止项目就可以改变界面
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
热部署失败需要修改IDEA配置点击此处查看