1.springboot自动装配原理@SpringBootApplication自动扫描主启动项所在的包以及子包
如果要扫描其他包需要依靠@ComponentScan
springboot自动装配的原理,当引入某些启动依赖时,当springboot启动时会调用@SpringbootApplication @EnableAutoConfiguraction @Import(AutoConfigurationImportSelector.class) 会自动加载相应的自动装配类。
2.springboot整合定时器Quartz.
1.导入定时器依赖
2.使用注解@EnableScheduling启动定时器
3.创建类通过工具
https://cron.qqe2.com/
获得定时器函数
3.分页插件PageHelper
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
调用分页controller层
@RestController
public class EmpFenye {
@Resource
private TabUser tabUser;
@GetMapping("list")
public PageInfo<User> list(@RequestParam Integer currentPage,@RequestParam Integer pageSize){
PageHelper.startPage(currentPage,pageSize);
List<User> list=tabUser.findAll();
PageInfo<User> pageInfo=new PageInfo<>(list);
return pageInfo;
}
}
4.thymeleaf模板引擎
resourcess下的static包下放入静态资源,如:js,css,layui等。可以直接被浏览器访问,templates.views包下的不能被直接访问.
使用thymeleaf
1.
引入相关依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.必须在html文件中引用下方代码
<html xmlns:th="http://www.thymeleaf.org">
3.可以使用thymeleaf标签库
<table>
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
<tr th:each="item : ${pageInfo.list}"
- <th th:text="${item.id}"></th>
<th th:text="${item.name}">姓名</th>
<th th:text="${item.age}">年龄</th>
<th th:if="${item.sex==0}">男</th>
<th th:if="${item.sex!=0}">女</th>
</tr>
</table>