spring boot 加载 jars(应用程序依赖项和外部文件系统 jars) [英] spring boot loading jars (application dependencies and external file system jars)

查看:23
本文介绍了spring boot 加载 jars(应用程序依赖项和外部文件系统 jars)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出设置 Spring Boot 应用程序的最佳方法是什么,使其具有自己的 jar 依赖项,但是当它作为 java -jar 命令运行时,在运行时将额外的 jars 添加到类路径中.哪种方法更有意义

I am trying to figure out what is the best way to setup a spring boot application in such a way that its has its own jar dependencies but additional jars are added to classpath at runtime when its being run as java -jar command. What approach makes more sense

  1. 使用原始 jar(未添加依赖项)并将所有 jar(应用程序和运行时)放在文件系统上的一个文件夹中,并使用 PropertiesLauncher 指定 jars 文件夹的 loader.path.

  1. Use the original jar (without dependencies added to it) and place all jars (application and runtime) in a folder on file system and use PropertiesLauncher to specify the loader.path to jars folder.

使用胖 jar(带有应用程序 jar)将额外的 jar 放在文件系统上,并以某种方式将那些作为需要添加到类路径的额外 jar 包括在内.不确定如何做到这一点.

Use the fat jar (with application jars) place the additional jars on the filesystem and somehow include those as additional jars that need to be added to classpath. Not sure how this can be done.

还有其他更好的方法可以做到这一点

Is there another better way to do this

推荐答案

PropertiesLauncher 旨在与胖 jar 一起使用,因此您应该能够保留胖 jar 并添加尽可能多的附加依赖项在外部位置随您喜欢,例如使用 loader.path=/opt/app/lib:lib.我想这是你的选项 2?如果它不起作用,我们可以在 github issue 中讨论.

The PropertiesLauncher was designed to work with fat jars, so you should be able to keep the fat jar and add as many additional dependencies as you like in an external location, e.g. with loader.path=/opt/app/lib:lib. I guess that's your option 2? If it doesn't work we can discuss in a github issue.

这篇关于spring boot 加载 jars(应用程序依赖项和外部文件系统 jars)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆