包含 Maven 依赖项的客户端 JAR
我正在构建一个包含使用 Spring 的客户端模块的服务。将实现客户端的服务不包含 spring,但它依赖于依赖于 Spring 的客户端。理想情况下,我希望客户端在 JAR 中包含所需的 Spring 依赖项,但我似乎不知道如何实现这一点。我见过一些使用 maven- assembly-plugin 的不同示例,但我宁愿不必使用“mvn clean package”之外的其他东西来完成此任务。
任何帮助表示赞赏。
I'm building a service which contains a client module which is using Spring. The service which will be implementing the client does not contain spring but it has a dependency on the client which has dependencies on Spring. Ideally I would like the client to include the needed Spring dependencies in the JAR but I can't seem to figure out how to accomplish this. I've seen a few different examples of using maven-assembly-plugin but I would prefer to not have to use something other than "mvn clean package" to accomplish this.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
maven-shade-plugin 允许您构建一个包含一些内容的 uber-jar (或全部)您的依赖项。它应该允许您做您需要做的事情。
The maven-shade-plugin allows you to build an uber-jar containing some (or all) of your dependencies. It should allow you to do what you need.
通过将程序集插件的单一目标绑定到项目的构建生命周期,您可以通过运行
mvn clean package
来完成您想要的任务。从 usage 页面剪切/粘贴 pom 配置以执行此操作 当然,您可以调整插件
以使用不同的预定义描述符,甚至使用单独的描述符文件。
By binding the assembly plugin's single goal to the project's build lifecycle, you can accomplish what you want by running
mvn clean package
.Cut/pasting the pom configuration to do this from the usage page of the plugin,
Of course, you would tweak either either to use a different predefined descriptor or even use a separate descriptor file.