在最近学习MyBatis的缓存机制中出现了新的问的问题在网上查找资料后才发现是没有给实体类实现Serializable接口导致的错误
解决以下问题只需要给报错提示的类实现Serializable接口且必须需要将实体类序列化
package com.itheima.pojo; import java.io.Serializable; public class Book implements Serializable { private Integer id; private String bookName; private double price; private String author; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getBookName() { return bookName; } public void setBookName(String bookName) { this.bookName = bookName; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } @Override public String toString() { return "Book{" + "id=" + id + ", bookName='" + bookName + '\'' + ", price=" + price + ", author='" + author + '\'' + '}'; } public Book(Integer id, String bookName, double price, String author) { this.id = id; this.bookName = bookName; this.price = price; this.author = author; } }
完成以下步骤之后就能完美解决问题啦
卑微大学生在线求点赞求点赞