maven之如何使用依赖库生成 JAR
think
阅读:11
2024-10-01 17:34:08
评论:0
使用Maven,如何生成带有依赖库的JAR?我正在使用 mvn 包,它不包括依赖库。
请您参考如下方法:
使用Maven Assembly Plugin并将其配置为 jar-with-depdencies
。
来自文档:
For example, imagine that our project produces a JAR. If we want to create an assembly binary that includes our project's dependencies, we can take advantage of one of the Assembly Plugin's prefabricated descriptors, as follows:
<project> [...] <build> [...] <plugins> <plugin> <!-- NOTE: We don't need a groupId specification because the group is org.apache.maven.plugins ...which is assumed by default. --> <artifactId>maven-assembly-plugin</artifactId> <version>2.3</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> [...] </project>
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。