Spring Boot的外部库文件夹 [英] External library folder for Spring Boot
问题描述
我想知道如何为我的Spring Boot应用程序外部化所有jdbc驱动程序,我不想在构建应用程序后将jdbc驱动程序插入到我的胖jar中。
I wonder how to externalize all jdbc drivers for my Spring Boot applications, I would not like to insert jdbc drivers into my fat jar once the application is built.
有没有办法设置java vm参数,通知jar执行应包含哪个外部文件夹?或者可能存在某种弹簧属性。
Is there any way to set a java vm parameter, informing which external folder should be included with jar execution? Or may else exists some kind of spring property for it.
例如:
java -DLib=file:\\\c:\Drivers -jar sample.jar
推荐答案
请参阅有关PropertiesLauncher的文档:
See the documentation about PropertiesLauncher:
- https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-property-launcher-features
看起来您可以使用 loader.path
属性来定义一个lib文件夹位置,其中包含要加载的jar文件 - 实际上是lib文件夹(内联jar)是默认位置:
Looks like you can use the loader.path
property to define a lib folder location, containing jars to load - in fact the lib folder (inline with the jar) is the default location:
loader.path(如果为空)默认为lib(表示本地目录或嵌套的目录,如果正在运行)来自存档)
loader.path (if empty) defaults to lib (meaning a local directory or a nested one if running from an archive)
这篇关于Spring Boot的外部库文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!