每次spring boot restart重启静态资源

时间:2018-01-19 16:07:49

标签: java spring eclipse gradle

有人能告诉我如何删除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

1 个答案:

答案 0 :(得分:1)

使用Apache Commons IO。

FileUtils.forceDeleteOnExit(new File("C:\\Users\\lukas\\workspace\\uploadingFiles\\src\\main\\resources\\static\\images"));

计划在JVM退出时删除文件。

参考: https://commons.apache.org/proper/commons-io/javadocs/api-release/index.html?org/apache/commons/io/FileUtils.html