【问题标题】:Spring modules as maven dependencies referenceSpring 模块作为 Maven 依赖项参考
【发布时间】:2014-04-16 20:57:35
【问题描述】:

我正在引用一个现有的 spring 项目,该项目对 Spring 框架的不同组件有许多 maven 依赖项。

我喜欢 Spring 以这种方式公开其模块的事实,因此您可以使用您需要的并丢弃您不需要的。

到目前为止,我已经在我的 pom.xml 文件中看到过类似的东西:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

我还查看了 Spring 网站,发现模块很好地组织到不同的项目中。但是,我在这里没有看到精确的 1:1 关系。例如,正如您在这个 pom.xml 文件中看到的那样,我依赖于 spring-core。好吧,如果我想将其映射回文档以便我可以进一步阅读,我将如何在此处进行操作:http://projects.spring.io?看起来项目的组织方式是:它们列出了一个项目,以及一个可以添加到项目中的快速入门 Maven 依赖项。那么,spring-core 呢?

似乎与网站上的特定项目没有确切的关系。我在这里列出的依赖项是独立的依赖项吗?还是有些实际上是传递依赖,比如:spring-context其实是spring-core的一个依赖?

是否有任何文档可以让我轻松地将 maven 依赖模块映射回 Spring 网站上的确切项目文档?

【问题讨论】:

    标签: spring maven web-applications spring-modules


    【解决方案1】:

    pom.xml 本身就是一种文档形式,也用于解决依赖关系。

    在命令行进入 pom.xml 所在的目录并输入以下命令:

    mvn dependency:tree
    

    然后打印出一棵依赖关系树,其中包含您在问题中提到的所有信息,即什么是顶级依赖关系,什么是传递依赖关系等。

    这是您发布的依赖项的示例:

    [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test-project ---
    [INFO] org.test.project:test-project:war:0.1-SNAPSHOT
    [INFO] +- org.springframework:spring-core:jar:3.2.4.RELEASE:compile
    [INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
    [INFO] +- org.springframework:spring-web:jar:3.2.4.RELEASE:compile
    [INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.2.4.RELEASE:compile
    [INFO] |  \- org.springframework:spring-beans:jar:3.2.4.RELEASE:compile
    [INFO] +- org.springframework:spring-webmvc:jar:3.2.4.RELEASE:compile
    [INFO] |  \- org.springframework:spring-expression:jar:3.2.4.RELEASE:compile
    [INFO] +- org.springframework:spring-oxm:jar:3.2.4.RELEASE:compile
    [INFO] \- org.springframework:spring-context:jar:3.2.4.RELEASE:compile
    

    【讨论】:

      猜你喜欢
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-02
      相关资源
      最近更新 更多