Maven:向jar添加本地依赖项 [英] Maven: Add local dependencies to jar
问题描述
我有依赖
<dependency>
<groupId>de.matthiasmann</groupId>
<artifactId>twl</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/TWL.jar</systemPath>
</dependency>
然后我执行 mvn assembly:assembly
。添加了所有原生文件和远程maven库,但没有这个jar。
Then I execute mvn assembly:assembly
. All natives files and remote maven libs are added, but there is no this jar.
更新
当我尝试按 java -jar myjar.jar
运行app时。它返回一个错误,表明上述依赖项中没有类(NoClassDefFoundError:de.matthiasmann.twl.ForExample)。
我想将这个jar中的类添加到myjar.jar(与maven对远程依赖项的作用相同)。我如何配置maven来做到这一点?
When I am trying to run app by java -jar myjar.jar
. It returns an error that there is no class from the above dependency (NoClassDefFoundError : de.matthiasmann.twl.ForExample).
I want to add classes from this jar to myjar.jar (the same what maven does with remote dependencies). How I can configure maven to do that?
推荐答案
参见具有依赖关系的Maven 2程序集:范围内的jar" system"不包括为什么不包括系统依赖项以及如何解决它,特别是 mvn install:install-file
代码就是你想要的。
See Maven 2 assembly with dependencies: jar under scope "system" not included for why system dependencies are not included and how you can work around it, specifically the mvn install:install-file
code is what you want.
这篇关于Maven:向jar添加本地依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!