springboot基础1

1.spring的优点:

1)依赖注入
2)面向切面编程

2.spring的缺点:

1)太多的xml配置文件

3.springboot特点:

解决了spring配置文件太多的问题,它有很多默认的配置,springboot其实是提供了一种快速使用spring的方式.

4.springBoot核心功能

1)起步依赖:将具有某种功能的坐标打包到一起
2)自动配置,该过程是spring自动完成的

5.SpringBoot快速入门
1)创建一个maven工程
2)添加springBoot的起步依赖

<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的引导类

@SpringBootApplication
public class MySpringBootApplication {
    public static void main(String[] args) {
        SpringApplication.run(MySpringBootApplication.class);
    }
}

4)Controller层的编写

@Controller
public class TestController {
    @RequestMapping("test")
    @ResponseBody
    public String test(){
        return "hello SpringBoot";
    }
}

6.SpringBoot热部署
1)添加依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

2)修改idea的配置

springboot基础1
3)然后 Shift+Ctrl+Alt+/,选择Registry
springboot基础1