简体   繁体   English

Maven:在其中一个依赖项中包含来自pom.xml的依赖项

[英]Maven: Include dependencies from pom.xml located in one of the dependencies

I am new to maven and was wondering how to include dependencies that exists in a pom.xml file located in one of my dependencies (without looking into that pom.xml and just doing a copy paste of the depencies into my pom.xml file)? 我是maven的新手,我想知道如何包含存在于我的一个依赖项中的pom.xml文件中的依赖项(无需查看该pom.xml并仅将依赖项复制粘贴到我的pom.xml文件中) ?

So this is what I want to achieve: 所以这就是我想要实现的:

My project structure: 我的项目结构:

在此处输入图片说明

I want to somehow in pom.xml tell maven to also make sure to include the dependencies inside of libPom.xml in the final jar file. 我想以某种方式在pom.xml中告诉Maven还要确保将libPom.xml内部的依赖项包含在最终的jar文件中。

Thanks 谢谢

Maven automatically includes transitive dependencies. Maven自动包含传递依赖项。

Just build with mvn clean install and have a look at the resulting jar file. 只需使用mvn clean install构建,然后查看生成的jar文件。

Caveat: the pom in the included library needs to be correct, and only dependencies with the correct (or default) classifier will be included. 注意:所包含库中的pom必须正确,并且仅包含具有正确(或默认) classifier依赖项。

To see how it works, try this: 要查看其工作原理,请尝试以下操作:

mvn dependency:tree

Maven automatically installs all related dependencies. Maven自动安装所有相关的依赖项。

In your case mvn clean compile and mvn clean install will be enough to load all the related dependencies. 在您的情况下, mvn clean compilemvn clean install足以加载所有相关的依赖项。

Hope it helps. 希望能帮助到你。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM