2
votes

I'm referencing an existing spring project that has many maven dependencies on different components of the Spring framework.

I like the fact that Spring exposes their modules this way so you can use what you need and discard what you don't.

So far I've seen something of this sort in my pom.xml file:

    <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>

I've also looked at the Spring website and have seen that the modules are nicely organized into different projects. However, I am not seeing an exact 1:1 relationship here. For example, as you can see in this pom.xml file, I have a depedency on spring-core. Well, if I wanted to map this back to the documentation so I can read further upon it, how would I do it here: http://projects.spring.io? It looks like the way the projects are organized is: they list a project, and a quickstart maven dependency you can add to your project. Well, where's spring-core?

There doesn't seem to be an exact relationship to a particular project on the site. The dependencies, I've listed here, are they stand-alone dependencies? Or are some actually transitive dependencies, for example: spring-context is actually a dependency of spring-core?

Is there any documentation where I can easily map the maven dependency module back to the exact project documentation on the Spring website?

1

1 Answers

1
votes

the pom.xml is a form of documentation itself, that also gets used to resolve the dependencies.

Go to the command line to the directory where the pom.xml is and type the following command:

mvn dependency:tree

and a tree of dependencies is printed out with all the information you mention in the question, namely what are the top dependencies, what are transitive dependencies, etc.

Here is an example for the dependencies you posted:

[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