1.SpringBoot核心启动器,包含各种springboot的配置日志等,创建项目时会自动引入该依赖
注解@controller、@Service、@Component、@Resource 是spring的,所以spring boot创建完成后就可以使用
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
2. junit测试,创建项目时会自动引入该依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
3.可执行的 Web 应用
支持注解:@RestController、@RequestMapping、@ResponseBody、@JsonFormat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
4.thymeleaf 页面模板技术
SpringBoot支持的thymeleaf页面模板技术,thymeleaf支持 th:text 规则
默认存放模板页面的路径在src/main/resources/templates 或者 src/main/view/templates
默认的页面文件后缀是.html
<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
5.mysql数据配置
配置mysql依赖时,不写版本号<version>xx.xx.xx</version>的话,就会引入mysql依赖的默认版本
SpringBoot2.1.x以后默认使用的是mysql 8版本,
SpringBoot2.1.x之前默认使用的是mysql 5.x版本
在配置数据源的时候,就有差异了
配置低版本 5.xx.xx:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
配置高版本 8.xx.xx:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/student?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
6.mybatis
数据处理层持久层框架,连接数据库
着重点放在了编写sql上,而不是通过jdbc传统方式来不断操作Connection、Statment、ResultSet
注解@Mapper 指定映射接口
application.properties配置文件中配置自动识别的xml:
mybatis.mapperLocations=classpath:mapper/*Mapper.xml
mybatis.type-aliases-package=com.smart.demo.entity
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
7.mybatis-plus
在mybatis基础上的升级版工具,避免了使用mybatis时需要编写大量的xml文件
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
8.springboot热部署
修改java代码后,不用重启项目就能直接最新测试,省略了不断修改代码不断重启项目的麻烦
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
9.Json格式转换工具Fastjson
Fastjson 是一个 Java 库,可以将 Java 对象转换为 JSON 格式,当然它也可以将 JSON 字符串转换为 Java 对象。
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
10.lombook
lombok最优秀的就是注解了,一个注解就干掉了很多代码
实体类中的注解.
@Data :直接可以省略了Get、Set方法
@Slf4j :不需要单独引入日志依赖和配置日志,直接 log.info( ) 打印日志
如何在IDE编译器 中使用lombok插件??
idea中可以直接在编译器中搜索下载,就不多阐述了
eclipse则需要从官网下载lombok.jar包,然后双击启动jar包,逐步操作,指向eclisp.exe,重启eclipse即可
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>