Spring 检查存储库保存方法是否成功保存到 Mongo Db 数据库

问题描述

我有一个 Spring Boot 应用程序和 Mongo Db 作为后端数据库。我正在使用存储库将学生对象保存为文档。我遇到的问题是我如何知道对象已成功保存为文档。

下面是我扩展 MongoRepository 的学生存储库


public interface StudentRepository extends MongoRepository<Student,String> {

}

下面是我在 RestController 类中使用的 StudentService 类中的方法

@AllArgsConstructor
@Service
public class StudentService {

    private final StudentRepository studentRepository;

    public void addNewStudent(Student student){

        studentRepository.save(student);

    }
}

我怎么知道

studentRepository.save(student);

已成功执行

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)