1.使用idea工具创建一个maven工程,该工程为普通的java工程即可

SpringBoot快速入门_spring

2. 添加SpringBoot的起步依赖

SpringBoot要求,项目要继承SpringBoot的起步依赖spring-boot-starter-parent

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>

SpringBoot要集成SpringMVC进行Controller的开发,所以项目要导入web的启动依赖

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

3.写SpringBoot引导类

package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


//标注SpringBoot的启动类 组合注解
@SpringBootApplication
public class Application {

public static void main(String[] args) {
// 代表运行SpringBoot的启动类,参数为SpringBoot启动类的字节码对象
SpringApplication.run(Application.class,args);
}
}

4. 编写Controller

package com;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {

@RequestMapping("/hello")
@ResponseBody
public String hello(){
return "hello, spring boot!";
}
}

5.执行SpringBoot起步类的主方法

SpringBoot快速入门_ide_02