user9183621
user9183621

Reputation:

Restart static resources every spring boot restart

Can someone tell me how to delete previous runtime operations on static Resources in Eclipse/Spring.

imageDir=new File("C:\\Users\\lukas\\workspace\\uploadingFiles\\src\\main\\resources\\static\\images");

Every next run must reset all previous runs operations in my resources

I am using Gradle(STS). Commands I used with my project(CMD Console):

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

Upvotes: 1

Views: 191

Answers (1)

Jeryl Cook
Jeryl Cook

Reputation: 1038

use Apache Commons IO.

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

Schedules a file to be deleted when JVM exits.

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

Upvotes: 1

Related Questions