【发布时间】:2021-08-30 22:24:35
【问题描述】:
我的 Spring Boot 应用程序中有一个 bean,如下所示:
@Component
public class DatabaseStudentLoader {
private final StudentRepository studentRepository;
private final Map<String, Student>> idToStudentEntityMap;
/**
* Instantiates a new Database loader.
*
* @param studentRepository the student repository
*/
public DatabaseStudentLoader(StudentRepository studentRepository) {
this.studentRepository = studentRepository;
}
public void doSomeOperation() {
//here I am constructing the map, reading entities from DB
...
}
}
在这里,我希望在我的 MySQL 数据库中更新/删除/创建实体后,立即刷新上述 bean。
【问题讨论】:
标签: java mysql spring spring-boot