├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ ├── maven-wrapper.properties
│ └── MavenWrapperDownloader.java
├── src
├── main
│ ├── resources
│ │ ├── banner.jpg
│ │ ├── application-sit.properties
│ │ ├── META-INF
│ │ │ └── spring.factories
│ │ ├── beans.xml
│ │ └── application.properties
│ ├── java
│ │ └── com
│ │ │ └── zs
│ │ │ └── demo
│ │ │ ├── dao
│ │ │ ├── DepartmentDao.java
│ │ │ ├── mapper
│ │ │ │ ├── Dept.xml
│ │ │ │ └── Emp.xml
│ │ │ └── EmployeeDao.java
│ │ │ ├── bean
│ │ │ ├── Pig.java
│ │ │ ├── MsgLog.java
│ │ │ ├── Car.java
│ │ │ ├── Book.java
│ │ │ ├── Article.java
│ │ │ ├── Department.java
│ │ │ ├── Desk.java
│ │ │ ├── User.java
│ │ │ └── Employee.java
│ │ │ ├── listener
│ │ │ ├── HelloApplicationRunner.java
│ │ │ ├── HelloCommandLineRunner.java
│ │ │ ├── HelloApplicationContextInitializer.java
│ │ │ ├── HelloDelegatingApplicationContextInitializer.java
│ │ │ └── HelloSpringApplicationRunListener.java
│ │ │ ├── repository
│ │ │ └── BookRepository.java
│ │ │ ├── config
│ │ │ ├── MyAMQPConfig.java
│ │ │ ├── MyCacheConfig.java
│ │ │ ├── MyConfig.java
│ │ │ └── MyRedisConfig.java
│ │ │ ├── controller
│ │ │ ├── HelloController.java
│ │ │ ├── DeptController.java
│ │ │ └── EmployeeController.java
│ │ │ ├── service
│ │ │ ├── BookService.java
│ │ │ ├── DeptService.java
│ │ │ └── EmployeeService.java
│ │ │ ├── ag
│ │ │ ├── sort
│ │ │ │ ├── insertSort.java
│ │ │ │ ├── bubbleSort.java
│ │ │ │ └── selectSort.java
│ │ │ ├── Test_NumberSum.java
│ │ │ ├── RobotCountWays.java
│ │ │ ├── TriangleSum.java
│ │ │ ├── hw
│ │ │ │ ├── randomSort.java
│ │ │ │ ├── dp.java
│ │ │ │ ├── findWordCount.java
│ │ │ │ └── lastWordLength.java
│ │ │ ├── SpaceReplace.java
│ │ │ └── Test_SortNumberOthers.java
│ │ │ ├── DemoApplication.java
│ │ │ └── ie
│ │ │ └── ie.md
│ └── webapp
│ │ ├── WEB-INF
│ │ ├── web.xml
│ │ └── test.jsp
│ │ └── hello.jsp
└── test
│ └── java
│ └── com
│ └── zs
│ └── demo
│ ├── cache
│ └── Springboot01CacheApplicationTests.java
│ ├── DemoApplicationTests.java
│ ├── rabbit
│ └── DemoApplicationTests.java
│ └── elastic
│ └── Springboot03ElasticApplicationTests.java
├── .gitignore
├── pom.xml
└── mvnw
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deserialization/springboot/main/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/banner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deserialization/springboot/main/src/main/resources/banner.jpg
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/src/main/java/com/zs/demo/dao/DepartmentDao.java:
--------------------------------------------------------------------------------
1 | package com.zs.demo.dao;
2 |
3 | import com.zs.demo.bean.Department;
4 | import org.apache.ibatis.annotations.Mapper;
5 |
6 | @Mapper
7 | public interface DepartmentDao {
8 |
9 |
10 | Department deptById(Integer id);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/resources/application-sit.properties:
--------------------------------------------------------------------------------
1 | mycar.brand=YDDD
2 | mycar.price=10000
3 |
4 | debug=true
5 | spring.banner.image.location=banner.jpg
6 | spring.profiles.active=sit
7 |
8 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xhwmppre
9 | spring.datasource.username=root
10 | spring.datasource.password=root
11 |
12 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 | * 数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。 9 | * 输入描述: 10 | * 输入数据有多组,每组占一行,由两个整数n(n < 10000)和m(m < 1000)组成,n和m的含义如前所述。 11 | *
12 | *
13 | * 输出描述: 14 | * 对于每组输入数据,输出该数列的和,每个测试实例占一行,要求精度保留2位小数。 15 | */ 16 | public class Test_NumberSum { 17 | 18 | public static void main(String[] args) { 19 | Scanner scanner = new Scanner(System.in); 20 | while (scanner.hasNext()) { 21 | double m = scanner.nextDouble(); 22 | double n = scanner.nextDouble(); 23 | double sum = 0; 24 | for (int i = 0; i < n; i++) { 25 | sum = sum + m; 26 | m = Math.pow(m, 0.5); 27 | } 28 | System.out.println(String.format("%.2f", sum));//保证小数掉过后两位有效数字 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * @author 么么么哒 7 | * @create 2021/1/9 8 | */ 9 | //@Component 10 | @ConfigurationProperties(prefix = "mycar") 11 | public class Car { 12 | private String brand; 13 | private Integer price; 14 | public String getBrand() { 15 | return brand; 16 | } 17 | 18 | public void setBrand(String brand) { 19 | this.brand = brand; 20 | } 21 | 22 | public Integer getPrice() { 23 | return price; 24 | } 25 | 26 | public void setPrice(Integer price) { 27 | this.price = price; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "Car{" + 33 | "brand='" + brand + '\'' + 34 | ", price=" + price + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/Book.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | public class Book { 4 | private String bookName; 5 | private String author; 6 | 7 | public Book() { 8 | } 9 | 10 | public Book(String bookName, String author) { 11 | this.bookName = bookName; 12 | this.author = author; 13 | } 14 | 15 | public String getBookName() { 16 | return bookName; 17 | } 18 | 19 | public void setBookName(String bookName) { 20 | this.bookName = bookName; 21 | } 22 | 23 | public String getAuthor() { 24 | return author; 25 | } 26 | 27 | public void setAuthor(String author) { 28 | this.author = author; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Book{" + 34 | "bookName='" + bookName + '\'' + 35 | ", author='" + author + '\'' + 36 | '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/config/MyConfig.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.config; 2 | 3 | import com.zs.demo.bean.Car; 4 | import com.zs.demo.bean.Pig; 5 | import com.zs.demo.bean.User; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ImportResource; 9 | 10 | /** 11 | * @author 么么么哒 12 | * @create 2021/1/9 13 | */ 14 | //@Configuration(proxyBeanMethods = false) 15 | //@ConditionalOnBean(name = "pig1") 16 | @ImportResource("classpath:beans.xml") 17 | @EnableConfigurationProperties(Car.class) 18 | public class MyConfig { 19 | @Bean 20 | public User user1(){ 21 | User user = new User("zs",12); 22 | user.setPig(pig1()); 23 | System.out.println(user.toString()); 24 | return user; 25 | } 26 | 27 | @Bean("pig11") 28 | public Pig pig1(){ 29 | return new Pig("zs"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/Article.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | import io.searchbox.annotations.JestId; 4 | 5 | public class Article { 6 | 7 | @JestId 8 | private Integer id; 9 | private String author; 10 | private String title; 11 | private String content; 12 | 13 | public Integer getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Integer id) { 18 | this.id = id; 19 | } 20 | 21 | public String getAuthor() { 22 | return author; 23 | } 24 | 25 | public void setAuthor(String author) { 26 | this.author = author; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public void setTitle(String title) { 34 | this.title = title; 35 | } 36 | 37 | public String getContent() { 38 | return content; 39 | } 40 | 41 | public void setContent(String content) { 42 | this.content = content; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/ag/sort/selectSort.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.ag.sort; 2 | 3 | public class selectSort { 4 | public static void main(String[] args) { 5 | int[] array = {3, 4, 1, 5, 2}; 6 | 7 | //剩余中找最小的 8 | for (int i = 0; i < array.length; i++) { 9 | //只为了找最小的 10 | int minPos = i; 11 | for (int j = i + 1; j < array.length; j++) { 12 | if (array[j] < array[minPos]) { 13 | minPos = j; 14 | } 15 | } 16 | swap(array, i, minPos); 17 | } 18 | print(array); 19 | } 20 | 21 | private static void swap(int[] array, int i, int minPos) { 22 | int temp = array[minPos]; 23 | array[minPos] = array[i]; 24 | array[i] = temp; 25 | } 26 | 27 | private static void print(int[] array) { 28 | for (int i = 0; i < array.length; i++) { 29 | System.out.print(array[i] + " "); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/Department.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | @Data 9 | public class Department implements Serializable { 10 | 11 | private static final long serialVersionUID = -9002515762089328752L; 12 | private Integer id; 13 | private String departmentName; 14 | 15 | 16 | public Department() { 17 | super(); 18 | // TODO Auto-generated constructor stub 19 | } 20 | public Department(Integer id, String departmentName) { 21 | super(); 22 | this.id = id; 23 | this.departmentName = departmentName; 24 | } 25 | public Integer getId() { 26 | return id; 27 | } 28 | public void setId(Integer id) { 29 | this.id = id; 30 | } 31 | public String getDepartmentName() { 32 | return departmentName; 33 | } 34 | public void setDepartmentName(String departmentName) { 35 | this.departmentName = departmentName; 36 | } 37 | @Override 38 | public String toString() { 39 | return "Department [id=" + id + ", departmentName=" + departmentName + "]"; 40 | } 41 | 42 | 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/Desk.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | import org.springframework.data.elasticsearch.annotations.Document; 4 | 5 | @Document(indexName = "atguigu",type = "book") 6 | public class Desk { 7 | private Integer id; 8 | private String bookName; 9 | private String author; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getBookName() { 20 | return bookName; 21 | } 22 | 23 | public void setBookName(String bookName) { 24 | this.bookName = bookName; 25 | } 26 | 27 | public String getAuthor() { 28 | return author; 29 | } 30 | 31 | public void setAuthor(String author) { 32 | this.author = author; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Book{" + 38 | "id=" + id + 39 | ", bookName='" + bookName + '\'' + 40 | ", author='" + author + '\'' + 41 | '}'; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.bean; 2 | 3 | /** 4 | * @author 么么么哒 5 | * @create 2021/1/9 6 | */ 7 | public class User { 8 | public String name; 9 | private Integer age; 10 | 11 | private Pig pig; 12 | 13 | public User(String name, Integer age) { 14 | this.name = name; 15 | this.age = age; 16 | } 17 | 18 | public User() { 19 | 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public Integer getAge() { 31 | return age; 32 | } 33 | 34 | public void setAge(Integer age) { 35 | this.age = age; 36 | } 37 | 38 | public Pig getPig() { 39 | return pig; 40 | } 41 | 42 | public void setPig(Pig pig) { 43 | this.pig = pig; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "User{" + 49 | "name='" + name + '\'' + 50 | ", age=" + age + 51 | ", pig=" + pig + 52 | '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/ag/RobotCountWays.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.ag; 2 | 3 | import java.util.Scanner; 4 | 5 | public class RobotCountWays { 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | while (scanner.hasNext()) { 9 | int x = scanner.nextInt(); 10 | int y = scanner.nextInt(); 11 | System.out.println(countWays1(x, y)); 12 | } 13 | } 14 | 15 | private static int countWays(int x, int y) { 16 | int[][] dp = new int[x][y]; 17 | for (int i = 1; i < y; i++) 18 | dp[0][i] = 1; 19 | for (int i = 1; i < x; i++) 20 | dp[i][0] = 1; 21 | for (int i = 1; i < x; i++) 22 | for (int j = 1; j < y; j++) 23 | dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; 24 | return dp[x - 1][y - 1]; 25 | } 26 | 27 | 28 | public static int countWays1(int x, int y) { 29 | if (x == 1 || y == 1) 30 | return 1; 31 | System.out.println(x); 32 | System.out.println(y); 33 | return countWays1(x - 1, y) + countWays1(x, y - 1); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/ag/TriangleSum.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.ag; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * 5 7 | * 7 8 | * 3 8 9 | * 8 1 0 10 | * 2 7 4 4 11 | * 4 5 2 6 5 12 | */ 13 | public class TriangleSum { 14 | static int n = 0; 15 | static int[][] array = null; 16 | static int[][] maxSum = null; 17 | public static void main(String[] args) { 18 | while(true){ 19 | Scanner scanner = new Scanner(System.in); 20 | n = scanner.nextInt(); 21 | array = new int[n + 1][n + 1]; 22 | maxSum = new int[n + 1][n + 1]; 23 | for (int i = 1; i <= n; i++) { 24 | for (int j = 1; j <= i; j++) { 25 | array[i][j] = scanner.nextInt(); 26 | maxSum[i][j] = -1; 27 | } 28 | } 29 | System.out.println(maxSum(1,1)); 30 | } 31 | } 32 | 33 | private static int maxSum(int x, int y) { 34 | if(maxSum[x][y] != -1) return maxSum[x][y]; 35 | if (x == n) 36 | return array[x][y]; 37 | else 38 | return Math.max(maxSum(x + 1,y),maxSum(x + 1,y + 1)) + array[x][y]; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/ag/hw/randomSort.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.ag.hw; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.util.TreeSet; 6 | import java.util.Scanner; 7 | import java.util.TreeSet; 8 | 9 | public class randomSort { 10 | /** 11 | * 明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性, 12 | * 他先用计算机生成了N个1到1000之间的随机整数(N≤1000) 13 | * ,对于其中重复的数字,只保留一个,把其余相同的数去掉, 14 | * 不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排好的顺序去找同学做调查。 15 | * 请你协助明明完成“去重”与“排序”的工作(同一个测试用例里可能会有多组数据,希望大家能正确处理)。 16 | */ 17 | 18 | public static void main(String[] args)throws Exception{ 19 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 20 | String str; 21 | 22 | while ((str = br.readLine()) != null) { 23 | boolean[] flags = new boolean[1001]; 24 | StringBuilder sb = new StringBuilder(); 25 | int n = Integer.valueOf(str); 26 | for (int i = 0; i < n; i++) 27 | flags[Integer.valueOf(br.readLine())]=true; 28 | 29 | for(int i=1;i<1001;i++){ 30 | if(flags[i]) 31 | sb.append(i).append("\n"); 32 | } 33 | sb.deleteCharAt(sb.length() - 1); 34 | System.out.println(sb.toString()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/ag/SpaceReplace.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.ag; 2 | 3 | 4 | public class SpaceReplace { 5 | public static void main(String[] args) { 6 | StringBuffer stringBuffer = new StringBuffer("we are lucky"); 7 | System.out.println(spaceReplace(stringBuffer)); 8 | } 9 | 10 | private static String spaceReplace(StringBuffer stringBuffer) { 11 | int numSpace = 0; 12 | for (int i = 0; i < stringBuffer.length(); i++) { 13 | if (stringBuffer.charAt(i) == ' ') { 14 | numSpace++; 15 | } 16 | } 17 | int oldIndex = stringBuffer.length() - 1; 18 | int stringLength = stringBuffer.length() + numSpace * 2; 19 | int newIndex = stringLength - 1; 20 | stringBuffer.setLength(stringLength); 21 | for (; oldIndex >= 0 && oldIndex < stringLength; --oldIndex) { 22 | if (stringBuffer.charAt(oldIndex) == ' ') { 23 | stringBuffer.setCharAt(newIndex--, '%'); 24 | stringBuffer.setCharAt(newIndex--, '2'); 25 | stringBuffer.setCharAt(newIndex--, '0'); 26 | } else { 27 | stringBuffer.setCharAt(newIndex--, stringBuffer.charAt(oldIndex)); 28 | } 29 | } 30 | return stringBuffer.toString(); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/controller/EmployeeController.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.controller; 2 | 3 | import com.zs.demo.bean.Employee; 4 | import com.zs.demo.service.EmployeeService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | public class EmployeeController { 12 | 13 | @Autowired 14 | EmployeeService employeeService; 15 | 16 | @GetMapping("/emp/{id}") 17 | public Employee getEmployee(@PathVariable("id") Integer id){ 18 | Employee employee = employeeService.getEmp(id); 19 | return employee; 20 | } 21 | 22 | @GetMapping("/emp") 23 | public Employee update(Employee employee){ 24 | Employee emp = employeeService.updateEmp(employee); 25 | 26 | return emp; 27 | } 28 | 29 | @GetMapping("/delemp") 30 | public String deleteEmp(Integer id){ 31 | employeeService.deleteEmp(id); 32 | return "success"; 33 | } 34 | 35 | @GetMapping("/emp/lastname/{lastName}") 36 | public Employee getEmpByLastName(@PathVariable("lastName") String lastName){ 37 | return employeeService.getEmpByLastName(lastName); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mycar.brand=YDDD 2 | mycar.price=10000 3 | 4 | debug=true 5 | spring.banner.image.location=banner.jpg 6 | spring.profiles.active=dev 7 | 8 | spring.datasource.url=jdbc:mysql://10.47.128.129:3306/xhwmppre 9 | spring.datasource.username=fabu 10 | spring.datasource.password=73R4_h8td6fE 11 | 12 | spring.mvc.view.prefix=/WEB-INF/ 13 | spring.mvc.view.suffix=.jsp 14 | 15 | 16 | # ���������õ����Զ�����Դ��������ܵ�properties�� 17 | server.servlet.encoding.enabled=true 18 | server.spring.http.encoding.charset=utf-8 19 | server.spring.http.encoding.force=true 20 | 21 | #mybatis.mapperLocations=classpath*:com/example/demo/mapper/*.xml 22 | #mybatis.configuration.map-underscore-to-camel-case=true 23 | 24 | # ָ��ȫ�������ļ�λ�� Ҳ����ָ��ӳ���ļ�λ�� 25 | mybatis.mapper-locations=classpath*:com/zs/demo/dao/mapper/*.xml 26 | mybatis.configuration.map-underscore-to-camel-case=true 27 | 28 | 29 | spring.redis.host=127.0.0.1 30 | 31 | logging.level.com.zs.demo.dao.mapper=debug 32 | 33 | #spring.rabbitmq.virtual-host= 34 | spring.rabbitmq.host=127.0.0.1 35 | spring.rabbitmq.username=guest 36 | spring.rabbitmq.password=guest 37 | 38 | #spring.kafka.bootstrap-servers=127.0.0.1:9092 39 | 40 | spring.elasticsearch.jest.uris=http://127.0.0.1:9200 41 | spring.data.elasticsearch.cluster-name=elasticsearch 42 | spring.data.elasticsearch.repositories.enabled = true 43 | spring.data.elasticsearch.cluster-nodes =127.0.0.1:9300 -------------------------------------------------------------------------------- /src/main/java/com/zs/demo/service/DeptService.java: -------------------------------------------------------------------------------- 1 | package com.zs.demo.service; 2 | 3 | import com.zs.demo.bean.Department; 4 | import com.zs.demo.dao.DepartmentDao; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Qualifier; 7 | import org.springframework.cache.Cache; 8 | import org.springframework.cache.annotation.Cacheable; 9 | import org.springframework.data.redis.cache.RedisCacheManager; 10 | import org.springframework.stereotype.Service; 11 | 12 | 13 | @Service 14 | public class DeptService { 15 | 16 | @Autowired 17 | DepartmentDao departmentDao; 18 | 19 | @Qualifier("rManager") 20 | @Autowired 21 | RedisCacheManager deptCacheManager; 22 | 23 | 24 | /** 25 | * 缓存的数据能存入redis; 26 | * 第二次从缓存中查询就不能反序列化回来; 27 | * 存的是dept的json数据;CacheManager默认使用RedisTemplate