maven中optional

作者: rejoice001 | 来源:发表于2017-12-06 21:03 被阅读3次

    How do optional dependencies work?

    Project-A -> Project-B
    

    The diagram above says that Project-A depends on Project-B. When A declares B as an optional dependency in its POM, this relationship remains unchanged. Its just like a normal build where Project-B will be added in its classpath.

    Project-X -> Project-A
    

    But when another project(Project-X) declares Project-A as a dependency in its POM, the optional dependency takes effect. You'll notice that Project-B is not included in the classpath of Project-X; you will need to declare it directly in your POM in order for B to be included in X's classpath.

    更多详细:http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

    从官网可以看出

    如果项目a依赖redis,而且方式为optional
    那么,如果项目b依赖项目a,项目b中的classpath是没有redis的依赖的,只有显示的添加redis的依赖才有(去掉optional)

    相关文章

      网友评论

        本文标题:maven中optional

        本文链接:https://www.haomeiwen.com/subject/uealixtx.html