When I use Serve Static Resources with Spring Boot 2.3.8.RELEASE , my configuration is as follows
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/", "classpath:/templates/", "file://temp/report");
super.addResourceHandlers(registry);
}
The project also implements direct access to the image on the hard disk corresponding to the server by accessing the url address http://localhost:8080/demo/123/123_1.png in the browser. The image address on the server is /temp/report/123/123_1.png.
this picture will be returned to the front-end user, the user can see it directly.
Recently, a problem has been found. The program has been running for a while, and now there is a need to update the picture. If a user clicks the picture on the page, the corresponding folder of the server is locked, and When the folder \tmp\report\123 is deleted through the interface, the interface returns an error of Unable to delete directory \tmp\report\123, it seems that the resource has not been released, what is the problem, and is there a corresponding solution?
Comment From: snicoll
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: bootstrap2025
Thank You @snicoll , As you suggested, i posted this question to [StackOverFlow] https://stackoverflow.com/questions/72299633/cannot-delete-static-folder-with-spring-boot