有人能告诉我如何删除Eclipse / Spring中静态资源的先前运行时操作。
imageDir=new File("C:\\Users\\lukas\\workspace\\uploadingFiles\\src\\main\\resources\\static\\images");
每次下一次运行都必须重置我资源中的所有先前运行操作
我正在使用Gradle(STS)。 我在项目中使用的命令(CMD控制台):
gradlew wrapper
gradle build
gradlew bootrun //every time I use this command to run Spring Boot
taskkill /F /PID <PID_NUMBER> //command to stop application
答案 0 :(得分:1)
使用Apache Commons IO。
FileUtils.forceDeleteOnExit(new File("C:\\Users\\lukas\\workspace\\uploadingFiles\\src\\main\\resources\\static\\images"));
计划在JVM退出时删除文件。