简体   繁体   English

如何在运行 maven 可执行文件 jar 时重用我的本地依赖项?

[英]How to reuse my local dependency while running maven executable jar?

I have maven project required dependencies in my local, I need to create an executable jar without dependency and need to use those dependencies in my local during the runtime, instead of packing it along with the project.我在本地有 maven 项目所需的依赖项,我需要创建一个没有依赖项的可执行 jar 并且需要在运行时在我的本地使用这些依赖项,而不是与项目一起打包。 how to create a maven project jar without dependency in eclipse and how to execute that jar feeding the local location where the dependencies exist?如何在 eclipse 中创建没有依赖关系的 maven 项目 jar 以及如何执行 Z68995FCBF432492D1548

You can use mvn dependency:build-classpath to generate the necessary classpath to run your jar您可以使用mvn dependency:build-classpath生成运行 jar 所需的类路径

https://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html https://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html

and then run your jar with java and adding the generated classpath as -cp argument.然后使用 java 运行java并将生成的类路径添加为-cp参数。

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

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