2021-06-21

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>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值