简体   繁体   English

Spring Boot Maven 插件和 requiresUnpack 目标目录

[英]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 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.到目前为止,我能够通过覆盖TMPTEMP环境变量来更改位置目标位置,但从长远来看,这听起来很糟糕。

Appriciate any help here.在这里获得任何帮助。

This problem is not specific to "requiresUnpack" only, this is how spring-boot/tomcat handles its temporary files.这个问题不仅仅针对“requiresUnpack”,这就是 spring-boot/tomcat 处理其临时文件的方式。 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有一个问题描述了这种行为: https : //github.com/spring-projects/spring-boot/issues/5009

Workarounds:解决方法:

  • use server.tomcat.basedir to define Tomcat base directory.使用server.tomcat.basedir定义 Tomcat 基目录。 If not specified, a temporary directory is used.如果未指定,则使用临时目录。
  • use -Djava.io.tmpdir=/var/tmp to start the app with different temporary directory.使用-Djava.io.tmpdir=/var/tmp以不同的临时目录启动应用程序。

Another solution would be to NOT unpack your library.另一种解决方案是不解压缩您的库。 Don't store it in your fat jar, but store it somewhere on the classpath.不要把它存储在你的胖罐子里,而是把它存储在类路径上的某个地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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