Maven 依赖项仅 jar [英] maven dependencies-only jar

查看:91
本文介绍了Maven 依赖项仅 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 maven 构建的 java 项目.该项目有几个依赖项,我正在寻找一种方法将我的项目打包成两个 jar - 一个用于实际项目类,另一个用于所有依赖项.

I am working on a java project that is build using maven. The project has several dependencies, I am looking for a way to package my project into two jars - one for the actual project classes and the other for all the dependencies together.

我搜索并发现了 maven shade 插件,该插件可以生成具有依赖项的单个 jar.因此,作为一种解决方法,我创建了另一个没有源的模块并将我的 pom 链接到该模块 - 然后使用 shade 插件我可以生成一个包含所有依赖项的 jar.但是感觉这个方法不对,有没有更好的方法?

I searched and found about the maven shade plugin which can produce a single jar with dependencies. So, as a workaround I created another module with no sources and link my pom to this module - then using the shade plugin I can generate one jar with all my dependencies. But this feels like the wrong way, is there any better way?

推荐答案

在这里查看 maven assembly 插件 http://maven.apache.org/plugins/maven-assembly-plugin/
您可以在程序集描述符中设置托管依赖项.
是的,@vikingsteve 的建议也是对的.

Checkout maven assembly plugin here http://maven.apache.org/plugins/maven-assembly-plugin/
You can have managed dependency set in assembly descriptor.
And yes @vikingsteve's suggestion is also right.

这篇关于Maven 依赖项仅 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆