什么是将大量 JAR 包捆绑并添加到 Maven 项目中的好方法?

huangapple go评论70阅读模式
英文:

What's a good way to bundle and add a whole bunch of JARs into a maven project?

问题

...而不必将每一个都指定为单独的依赖项呢?

因此,我必须使用由专有第三方软件提供的许多Java依赖项,这些依赖项以可下载的SDK形式提供。我真的想使用Maven来进行依赖关系和生命周期管理,但也不想将几十个JAR文件逐个添加为单独的依赖项。在解决这个问题时,什么是最优雅的解决方案?

英文:

...without specifying each and every one as a separate dependency?

So I have to work with a whole bunch of java dependencies provided by a proprietary third party software in the form of a downloadable SDK. I really want to use maven for dependency and lifecycle management, but also can't be bothered to add several dozens of JARs as individual dependencies. What's the most elegant solution to work around this issue?

答案1

得分: 2

每个 JAR 文件都必须在某个地方作为 <dependency> 添加。

因此,如果您只有一个项目使用 100 个 JAR 文件作为依赖,您需要添加所有这些依赖项(每个都作为 <dependency>)。

如果有多个项目使用相同的 JAR 文件,我会遵循 Conffusion 建议的方法,创建一个带有依赖项的 POM 文件,然后在所有项目中使用该 POM 文件。

Maven 无法将“一个 JAR 文件目录”添加到依赖项中。

英文:

Each jar must be added as a &lt;dependency&gt; somewhere.

So if you have just one project that uses 100 JARs as dependencies, you need to add all those dependencies (each as a &lt;dependency&gt;) entry.

If you have several projects using the same JARs, I would follow Conffusion's advice to create a POM with the dependencies and then use that POM in all the projects.

Maven cannot add "a directory of JARs" to the dependencies.

huangapple
  • 本文由 发表于 2020年10月19日 22:23:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/64429371.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定