我有一份学生名单。我想做编辑。更改名称、姓氏和头像。我写了代码,但它不起作用,数据没有被编辑。你可以看到为什么它对我不起作用。没有错误,它只是没有改变任何东西。编辑后姓名和头像不变学生服务public interface StudentService { List<Student> getAllStudents(); Student getStudentById(Long id); boolean saveStudent(Student student); boolean deleteStudentById(Long id); File loadAvatarByFileName(String filename); File saveAvatarImage(MultipartFile avatarImage) throws IOException; Student updateStudent(String name, String surname, MultipartFile avatar, Student targetStudent) throws IOException;}
1 回答

HUH函数
TA贡献1836条经验 获得超4个赞
该错误表明另一个进程正在使用该文件,因此无法将其删除。
您是否在另一个程序中打开了给定的文件?
可能是您的代码在您尝试删除文件时打开文件/在另一个地方保持打开状态吗?
我看到您的 StudentServiceImpl.updateStudent 调用了Files.deleteIfExists(Paths.get(storageLocation + File.separator + oldAvatarName));
两次。根据堆栈跟踪,违规行是StudentServiceImpl.java:122
. 这两行中哪一行是数字 122?
添加回答
举报
0/150
提交
取消