gpt4 book ai didi

maven - 如何使用依赖库生成 JAR?

转载 作者:行者123 更新时间:2023-12-01 11:02:05 24 4
gpt4 key购买 nike

使用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>

关于maven - 如何使用依赖库生成 JAR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9798389/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com