SpringBoot

一.Spring的优缺点

*是javaEE的轻量级替代品,解耦

*配置多,bean依赖关系多,依赖配置版本冲突

二.springBoot

*无需xml配置,提供了快速使用Spring的方式

*核心功能

  *起步依赖

  *自动配置

三.环境搭建

*Maven,无骨架

*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>
知识兔

*引导类 MySpringBootApplication类

  *main方法

  *SpringApplication.run(MySpringBootApplication.class);

  *@SpringBootApplication

  *使用main()方法执行springboot

*springBooot可以热部署:修改完代码不用重启动

  *添加功能依赖

<!--热部署配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
知识兔

  *设置idea自动编译

*idea快速创建SpringBoot

  *选择web功能

  *选择Thymeleaf引擎

  *SqL选择

  *删除文件

  *建立controller类测试

 四.配置文件

*覆盖默认信息

*application.yml

*properties高于yml文件

*pom中配置映射执行器

五.集成MyBatis

六.集成JUint

七.集成SpringDataJpa

八.集成redis

计算机