简体   繁体   English

在运行spring boot jar时使用外部jar作为依赖文件

[英]Using external jar as dependency file while running spring boot jar

I have a Maven-Springboot project setup. 我有一个Maven-Springboot项目设置。 After doing a mvn install I can run the jar file in command prompt using java -jar <my-jar-file.jar> 执行mvn install我可以使用java -jar <my-jar-file.jar>在命令提示符下运行jar文件

There was a dependency to a jar say as-common-1.0.0.jar that is there in my-jar-file.jar . my-jar-file.jar中存在一个依赖项,例如as-common-1.0.0.jar -1.0.0.jar Now I want to override the version of this dependent jar at run time by giving an external jar. 现在,我想在运行时通过提供一个外部jar来覆盖此从属jar的版本。 something like: 就像是:

java -jar my-jar-file.jar using as-common-1.0.1.jar

I went through many SO posts like this include external jar when running java -jar but they didn't help. 在运行java -jar时经历了很多这样的SO帖子, 包括外部jar,但是它们没有帮助。

is it achievable? 这是可以实现的吗?

EDIT: The issue we have is many of our applications depend upon one of our internal framework jar which gets updated(version) often. 编辑:我们遇到的问题是我们的许多应用程序都依赖于我们的内部框架jar之一,该jar经常更新(版本)。 So every time changing the pom file and re-deploying all the apps doesn't look feasible to us. 因此,每次更改pom文件并重新部署所有应用程序在我们看来都不可行。 We want somehow the dependency of this particular jar is given at run time. 我们希望以某种方式在运行时给出此特定jar的依赖关系。 Any idea regarding best possible way to manage this scenario ? 关于管理这种情况的最佳方法有什么想法

No, this is not sensible. 不,这不明智。 At best, you would load classes twice and this may/may not work. 充其量,您将加载两次类,这可能/可能不起作用。

If you build a complete jar containing everything, you cannot swap content at runtime. 如果构建包含所有内容的完整jar,则无法在运行时交换内容。 You need to rebuild it. 您需要重建它。

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

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