How to figure out the jars that the dependencies in the maven's pom.xml depend on?

I am very interested in how I can find out what are the jars that the dependences in the maven's pom.xml depend on.

I am used to doing the adding of libraries (jars) myself in my web application project. I came across this need when I was trying to configure the spring 3.0 samples. I really dislike that everything has to go through maven with spring 3.0.x. At this point it seems that I cannot dig deeper in the maven's dependency maze and learning it looks like a must. But I would really appreciate if someone can tell me a way I can find out this info.

For example, for the following pom.xml, I would like to know what the dependency with artifactId spring-context depends on. (I can see that it depends on commons-logging, since the creator of the sample excludes it - wanted to use slf4j instead of commons-logging.). I would like to find out the rest of the dependences for the dependency with artifactId spring-context, and the same for the rest of the dependences! How can I do this?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>mvc-ajax</artifactId>
<name>mvc-ajax</name>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <org.slf4j.version>1.6.1</org.slf4j.version>
</properties>
<dependencies>

    <!--  Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
             </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>runtime</scope>
    </dependency>

    <!--  JSR 303 with Hibernate Validator -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.1.0.Final</version>
    </dependency>

    <!--  Joda Time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>1.6.2</version>
        <scope>runtime</scope>
    </dependency>

    <!-- Jackson JSON Mapper -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.6.4</version>
    </dependency>

    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Test -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<repositories>
    <!-- For Hibernate Validator -->
    <repository>
        <id>org.jboss.repository.release</id>
        <name>JBoss Maven Release Repository</name>         
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        <snapshots><enabled>false</enabled></snapshots>         
    </repository>       
</repositories>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

Kind Regards,
Despot

РЕДАКТИРОВАТЬ (некоторые следуют ответу Шона):
1) Загрузите maven (я загрузил версию 2.2.1) и следуйте инструкциям по установке, приведенным там.
2) Затем откройте командную строку и перейдите в каталог pom.xml
3) Выполните команду "mvn dependency: tree" в соответствии с рекомендациями. (Я пробовал использовать -DoutputFile = "somePath" или -Dinclude = spring-context -> он не записывал в файл, представленный в пути, и он выбирал все зависимости вместо spring-context - независимо от того, будет ли общая команда достаточно). Подождите, пока система загрузит всю необходимую информацию, и в итоге вы получите что-то вроде этого:

[INFO] [dependency:tree {execution: default-cli}]
[INFO] org.springframework.samples:mvc-ajax:war:1.0.0-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:
      compile
[INFO] |  \- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:runtime
[INFO] +- log4j:log4j:jar:1.2.16:runtime
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.1.0.Final:compile
[INFO] +- joda-time:joda-time:jar:1.6.2:runtime
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.6.4:compile
[INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.6.4:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- junit:junit:jar:4.7:test
[INFO] \- org.springframework:spring-test:jar:3.0.5.RELEASE:test
[INFO] ---------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ---------------------------------------------------------------
[INFO] Total time: 1 minute 8 seconds
[INFO] Finished at: Tue Jan 04 16:53:45 CET 2011
[INFO] Final Memory: 12M/25M
[INFO] ---------------------------------------------------------------

Вы можете загрузить банки с помощью Jarvana (просто введите jarvana + имя банки) или можете использовать svn команда checkout.

hibernate-validator: jar: 4.1.0.Final в Jarvana возвращает ошибку (нет версии 4.1.0 Final -> только 4.0.2 Final
Also org.codehaus.jackson-mapper-asl 1.6.4 could not be found - only 1.6.2 (same goes to the jackson-core-asl). I am presuming that the same would happen if you used maven to build your project.

After I included all the needed jars, I started the server in debug mode and this happened:

TIME org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\somePath\mvc-ajax3.0\WEB-INF\lib\jsp-api-2.1.jar) - jar not loaded. 
See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/jsp/JspPage.class
TIME org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\somePath\mvc-ajax3.0\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. 
See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

This means (I think) that those jars are found twice. Deleting them done the job for me. Seams like the pom.xml is not valid for this sample.

It took too much time for me to download the jars manually and to "fight" all the project configuration, so I guess is best to learn some Maven if you are trying to start with Spring 3.0.

6
задан despot 5 January 2011 в 09:24
поделиться