SpringBoot高级整合 尚硅谷雷锋阳 学习笔记
这里写目录标题
Springboot与缓存
JSR107缓存规范
相信大家都能看得懂
使用JSR107需要导入下面的依赖包
Spring缓存抽象
代码实现
搭建基本环境
创建数据库
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`departmentName` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`lastName` VARCHAR(255) DEFAULT NULL,
`email` VARCHAR(255) DEFAULT NULL,
`gender` INT(2) DEFAULT NULL,
`d_id` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO employee(lastName,email,gender,d_id)VALUES('zhangsan','zhangsan@qq.com',1,1);
INSERT INTO employee(lastName,email,gender,d_id)VALUES('lisi','lisi@qq.com',0,2);
建两个bean实体类
package com.luyi.bean;
/**
* @author 卢意
* @create 2020-11-24 9:00
*/
public class Department {
private Integer id;
private String departmentName;
public Department() {
super();
// TODO Auto-generated constructor stub
}
public Department(Integer id, String departmentName) {
super();
this.id = id;
this.departmentName = departmentName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
@Override
public String toString() {
return "Department [id=" + id + ", departmentName=" + departmentName + "]";
}
}
package com.luyi.bean