简体   繁体   中英

Spring Boot Maven Plugin and requiresUnpack target directory

I have a case where I need to unpack the library using the:

spring-boot:repackage:requiresUnpack

Otherwise, the other library from the project is not able to work properly. As stated in the link, the selected libraries are unpacked and copied over to the temporary directory. Unpacking the libraries to the temp directory isn't great idea if I would like to keep the application running longer that the temp files expiration time. The files would be removed and application will just stop working properly.

  • Is there a way to specify the different target directory?
  • Is there a reason why the temp location is good place for the application libraries?

So far, I was able to change the location target location via overwriting the TMP and TEMP environment variables but that sounds like terrible idea in the long run.

Appriciate any help here.

This problem is not specific to "requiresUnpack" only, this is how spring-boot/tomcat handles its temporary files. So it might also surprise you in other areas.

There is an issue describing that behavior: https://github.com/spring-projects/spring-boot/issues/5009

Workarounds:

  • use server.tomcat.basedir to define Tomcat base directory. If not specified, a temporary directory is used.
  • use -Djava.io.tmpdir=/var/tmp to start the app with different temporary directory.

Another solution would be to NOT unpack your library. Don't store it in your fat jar, but store it somewhere on the classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM