您的位置:首页 > 其它

Maven-06可选依赖

2011-08-29 21:35 148 查看
 假设有这样一个依赖关系,项目A依赖于项目B,项目B依赖于项目X和Y,B对于X和Y的依赖是可选依赖:A->B、B->X(可选)、B->Y(可选)。根据传递依赖的定义,如果所有这三个依赖范围都是compile,那木X、Y就是A的compile返元的传递性依赖,然而,由于这里XY是可选依赖,依赖不会得以传递。换句话说,XY将不会对A有任何影响。

optional:

Marks optional a dependency when this project itself is a dependency. Confused? For example,

imagine a project A that depends upon project B to compile a portion of code that may not

be used at runtime, then we may have no need for project B for all project. So if project X

adds project A as its own dependency, then Maven will not need to install project B at all.

Symbolically, if => represents a required dependency, and --> represents optional, although

A=>B may be the case when building A X=>A-->B would be the case when building X.

In the shortest terms, optional lets other projects know that, when you use this project, you do

not require this dependency in order to work correctly.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  maven