【发布时间】:2017-12-04 15:31:22
【问题描述】:
我想构建项目,以便最终 jar 将所有依赖项包含在单个 jar 文件中 (如果不可能,将依赖项中的类包含到 jar 文件中) 我关注了Including dependencies in a jar with Maven 的线程,但它包括在内 我什至没有在我的 pom.xml 中提到的依赖项。这是我的 POM,它只有两个依赖项。
我希望在构建 final 时,它包含 pom 中提到的特定依赖项(以类或 jar 形式)
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.myProject</groupId>
<artifactId>utils</artifactId>
<version>1</version>
</dependency>
【问题讨论】:
-
看看maven shade插件maven.apache.org/plugins/maven-shade-plugin
-
你看到的其他依赖可能是你的依赖的依赖...你不想包含它们吗?
-
是的,我不想包含它们
-
@suboptimal 你能给我一些例子吗,因为我不知道阴影如何帮助我
-
@user3198603 也许我在第一步误读了你的问题。您想获得一个 jar 文件,其中仅包含您在
pom.xml中提到的依赖项,独立于范围?但是排除上述依赖项的依赖项可能会导致应用程序无法正常运行。