0

所以我有

 <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>1.8.3</version>
            <scope>${defaultScope}</scope>
        </dependency>

我包括了这个

   <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-web</artifactId>
            <version>1.0.2.RELEASE</version>
        </dependency>

它本身包括这个

 <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.3</version>
      <scope>test</scope>
    </dependency>

这导致没有找到 jsonwrapper 的类。

我更新了原始版本的 jackson 依赖项,使其与包含 spring-social 的版本保持同步,现在它可以工作了。

这看起来相当脆弱/不友好,我应该做些什么来避免这些问题吗?

4

2 回答 2

1

您可以使用检查依赖项的依赖项

mvn dependency:tree -Dverbose

在你的情况下,它会发出:

+- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
|  +- org.codehaus.jackson:jackson-core-asl:jar:1.8.3:compile
|  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.3:compile
|     \- (org.codehaus.jackson:jackson-core-asl:jar:1.8.3:compile - omitted for duplicate)
\- org.springframework.social:spring-social-web:jar:1.0.2.RELEASE:compile
   +- org.springframework:spring-webmvc:jar:3.1.0.RELEASE:compile
   |  +- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
   |  +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
   |  |  \- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  +- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
   |  |  +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
   |  |  |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
   |  |  |  +- (org.springframework:spring-asm:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  |  +- (org.springframework:spring-beans:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  |  \- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  +- (org.springframework:spring-beans:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  +- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  +- (org.springframework:spring-expression:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  \- (org.springframework:spring-asm:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  +- org.springframework:spring-context-support:jar:3.1.0.RELEASE:compile
   |  |  +- (org.springframework:spring-beans:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  +- (org.springframework:spring-context:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  \- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  +- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
   |  |  +- (org.springframework:spring-asm:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  |  \- commons-logging:commons-logging:jar:1.1.1:compile
   |  +- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
   |  |  \- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  \- (org.springframework:spring-web:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   +- javax.inject:javax.inject:jar:1:compile
   +- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
   |  +- aopalliance:aopalliance:jar:1.0:compile
   |  +- (org.springframework:spring-beans:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  +- (org.springframework:spring-context:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   |  \- (org.springframework:spring-core:jar:3.1.0.RELEASE:compile - omitted for duplicate)
   \- org.springframework.social:spring-social-core:jar:1.0.2.RELEASE:compile
      \- (org.springframework:spring-web:jar:3.1.0.RELEASE:compile - omitted for duplicate)

据我所知,这不spring-social-web包括jackson-mapper-asl

于 2013-05-12T19:24:27.173 回答
0

您可以使用以下部分告诉 Maven 忽略传递依赖项<exclusions>

<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-web</artifactId>
    <version>1.0.2.RELEASE</version>
    <exclusions>
        <exclusion>
            <artifactId>org.codehaus.jackson</artifactId>
            <groupId>jackson-mapper-asl</groupId>
        </exclusion>
    </exclusions>
</dependency>

有了这个定义,Maven 将只使用您之前定义的依赖项(1.8.3 版本)。但请注意,有时这会导致其他问题,例如 spring-social-web 可能会使用 1.8.3 版本中不存在的功能。

于 2013-05-15T16:20:21.333 回答